WebGLRenderingContext.isContextLost()
WebGLRenderingContext.isContextLost()
方法返回一个Boolean
标记 WebGL 的上下文是否已经丢失。
语法
gl.isContextLost();
返回值
Boolean
。如果上下文丢失则返回 true,否则返回 false。
样例
比如,当检查程序链接成功时,你也可以检查是否上下文已经丢失。
js
gl.linkProgram(program);
if (!gl.getProgramParameter(program, gl.LINK_STATUS) && !gl.isContextLost()) {
var info = gl.getProgramInfoLog(program);
console.log("Error linking program:\n" + info);
}
规范
Specification |
---|
WebGL Specification # 5.14.13 |
浏览器兼容性
BCD tables only load in the browser
参见
- The
WebGLContextEvent
signals changes in the context state.