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 July 2015.
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 |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
isContextLost |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
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.
参见
- The
WebGLContextEvent
signals changes in the context state.