WebGLRenderingContext.isContextLost()

WebGLRenderingContext.isContextLost() 方法返回一个Boolean 标记WebGL的上下文是否已经丢失。

语法

gl.isContextLost();

返回值

 Boolean。如果上下文丢失则返回true,否则返回false。

样例

比如,当检查程序链接成功时,你也可以检查是否上下文已经丢失。

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 Status Comment
WebGL 1.0
WebGLRenderingContext.isContextLost
Recommendation Initial definition.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support 9Edge Full support 12Firefox Full support 4IE Full support 11Opera Full support 12Safari Full support 5.1WebView Android Full support YesChrome Android Full support 25Edge Mobile Full support YesFirefox Android Full support YesOpera Android Full support 12Safari iOS Full support 8.1Samsung Internet Android Full support Yes

Legend

Full support  
Full support

另见

文档标签和贡献者

标签: 
此页面的贡献者: shenwenkai
最后编辑者: shenwenkai,