WebGLContextEvent

WebContextEvent 接口属于 WebGL API 的一部分,同时也是生成用来对 WebGL 渲染上下文作响应的事件接口。

继承

此接口从它的父接口 Event继承属性和方法。

Event WebGLContextEvent

属性

此接口从它的父接口 Event继承属性。

WebGLContextEvent.statusMessage (en-US)

一个包含事件额外信息的只读属性。

方法

此接口本身并没有定义任何方法,而是从它的父接口 Event 继承方法。

示例

使用 WEBGL_lose_context 插件,你可以模拟 webglcontextlostwebglcontextrestored (en-US) 事件:

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

浏览器兼容性

BCD tables only load in the browser

相关内容