diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/webglcontextevent/index.html | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/webglcontextevent/index.html')
-rw-r--r-- | files/zh-cn/web/api/webglcontextevent/index.html | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/webglcontextevent/index.html b/files/zh-cn/web/api/webglcontextevent/index.html new file mode 100644 index 0000000000..394341191e --- /dev/null +++ b/files/zh-cn/web/api/webglcontextevent/index.html @@ -0,0 +1,74 @@ +--- +title: WebGLContextEvent +slug: Web/API/WebGLContextEvent +translation_of: Web/API/WebGLContextEvent +--- +<div>{{APIRef("WebGL")}}</div> + +<p><strong>WebContextEvent</strong> 接口属于 <a href="/en-US/docs/Web/API/WebGL_API">WebGL API</a> 的一部分,同时也是生成用来对 WebGL 渲染上下文作响应的事件接口。</p> + +<h2 id="继承">继承</h2> + +<p><em><em>此接口从它的父接口 {{domxref("Event")}}继承属性和方法。</em></em></p> + +<p>{{InheritanceDiagram}}</p> + +<h2 id="属性">属性</h2> + +<p><em><em>此接口从它的父接口 {{domxref("Event")}}继承属性。</em></em></p> + +<dl> + <dt>{{domxref("WebGLContextEvent.statusMessage")}}</dt> + <dd>一个包含事件额外信息的只读属性。</dd> +</dl> + +<h2 id="方法">方法</h2> + +<p><em>此接口本身并没有定义任何方法,而是<em>从它的父接口 {{domxref("Event")}}继承方法。</em></em></p> + +<h2 id="示例">示例</h2> + +<p>使用 {{domxref("WEBGL_lose_context")}} 插件, 你可以模拟 {{Event("webglcontextlost")}} 和 {{Event("webglcontextrestored")}} 事件:</p> + +<pre class="brush: js">var canvas = document.getElementById('canvas'); +var gl = canvas.getContext('webgl'); + +canvas.addEventListener('webglcontextlost', function(e) { + console.log(e); +}, false); + +gl.getExtension('WEBGL_lose_context').loseContext(); + +// 记录了 "webglcontextlost" 类型的 WebGLContextEvent 事件 +</pre> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">规范</th> + <th scope="col">状态</th> + <th scope="col">注释</th> + </tr> + <tr> + <td>{{SpecName('WebGL', "#5.15", "WebGLContextEvent")}}</td> + <td>{{Spec2('WebGL')}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("api.WebGLContextEvent")}}</p> + +<h2 id="相关内容">相关内容</h2> + +<ul> + <li>{{domxref("WebGLRenderingContext.isContextLost()")}}</li> + <li>{{domxref("WEBGL_lose_context")}}, {{domxref("WEBGL_lose_context.loseContext()")}}, {{domxref("WEBGL_lose_context.restoreContext()")}}</li> + <li>事件: <a href="/en-US/docs/Web/API/HTMLCanvasElement/webglcontextlost_event">webglcontextlost</a>, <a href="/en-US/docs/Web/API/HTMLCanvasElement/webglcontextrestored_event">webglcontextrestored</a>, <a href="/en-US/docs/Web/API/HTMLCanvasElement/webglcontextcreationerror_event">webglcontextcreationerror</a></li> +</ul> |