WebGLRenderingContext.isContextLost()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
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> |
浏览器兼容性
Loading…
参见
- The
WebGLContextEventsignals changes in the context state.