WebGLContextEvent
Baseline Widely available *
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
* Some parts of this feature may have varying levels of support.
WebContextEvent 接口属于 WebGL API 的一部分,同时也是生成用来对 WebGL 渲染上下文作响应的事件接口。
继承
此接口从它的父接口 Event
继承属性和方法。
属性
此接口从它的父接口 Event
继承属性。
WebGLContextEvent.statusMessage
-
一个包含事件额外信息的只读属性。
方法
此接口本身并没有定义任何方法,而是从它的父接口 Event
继承方法。
示例
使用 WEBGL_lose_context
插件,你可以模拟 webglcontextlost
和 webglcontextrestored
事件:
js
var canvas = document.getElementById("canvas");
var gl = canvas.getContext("webgl");
canvas.addEventListener(
"webglcontextlost",
function (e) {
console.log(e);
},
false,
);
gl.getExtension("WEBGL_lose_context").loseContext();
// 记录了 "webglcontextlost" 类型的 WebGLContextEvent 事件
规范
Specification |
---|
WebGL Specification # 5.15 |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
WebGLContextEvent | ||||||||||||
WebGLContextEvent() constructor | ||||||||||||
statusMessage | ||||||||||||
Available in workers |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- Experimental. Expect behavior to change in the future.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.