From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../webglrenderingcontext/iscontextlost/index.html | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 files/zh-cn/web/api/webglrenderingcontext/iscontextlost/index.html (limited to 'files/zh-cn/web/api/webglrenderingcontext/iscontextlost') diff --git a/files/zh-cn/web/api/webglrenderingcontext/iscontextlost/index.html b/files/zh-cn/web/api/webglrenderingcontext/iscontextlost/index.html new file mode 100644 index 0000000000..d8135d7364 --- /dev/null +++ b/files/zh-cn/web/api/webglrenderingcontext/iscontextlost/index.html @@ -0,0 +1,58 @@ +--- +title: WebGLRenderingContext.isContextLost() +slug: Web/API/WebGLRenderingContext/isContextLost +tags: + - WebGL上下文丢失 +translation_of: Web/API/WebGLRenderingContext/isContextLost +--- +
{{APIRef("WebGL")}}
+ +

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

+ +

语法

+ +
gl.isContextLost();
+ +

返回值

+ +

 {{jsxref("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);
+}
+ +

规范

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("WebGL", "#5.14.13", "WebGLRenderingContext.isContextLost")}}{{Spec2("WebGL")}}Initial definition.
+ +

浏览器兼容性

+ + + +

{{Compat("api.WebGLRenderingContext.isContextLost")}}

+ +

另见

+ + -- cgit v1.2.3-54-g00ecf