diff options
Diffstat (limited to 'files/zh-cn/web/api/webgl_lose_context/restorecontext')
-rw-r--r-- | files/zh-cn/web/api/webgl_lose_context/restorecontext/index.html | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/webgl_lose_context/restorecontext/index.html b/files/zh-cn/web/api/webgl_lose_context/restorecontext/index.html new file mode 100644 index 0000000000..4313234364 --- /dev/null +++ b/files/zh-cn/web/api/webgl_lose_context/restorecontext/index.html @@ -0,0 +1,68 @@ +--- +title: WEBGL_lose_context.restoreContext() +slug: Web/API/WEBGL_lose_context/restoreContext +tags: + - API + - Method + - Reference + - WebGL + - WebGL extension +translation_of: Web/API/WEBGL_lose_context/restoreContext +--- +<div>{{APIRef("WebGL")}}</div> + +<p><strong>WEBGL_lose_context.restoreContext()</strong> 属于 <a href="/en-US/docs/Web/API/WebGL_API">WebGL API</a>。 , 一般用来模拟 {{domxref("WebGLRenderingContext")}} 的上下文恢复。</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox">gl.getExtension('WEBGL_lose_context').restoreContext();</pre> + +<h3 id="抛出错误">抛出错误</h3> + +<ul> + <li><code>INVALID_OPERATION</code> 上下文尚未丢失</li> +</ul> + +<h2 id="示例">示例</h2> + +<p>你可以用这个方法模拟 <code><a href="/en-US/docs/Web/API/HTMLCanvasElement/webglcontextrestored_event">webglcontextrestored</a></code> 事件:</p> + +<pre class="brush: js">var canvas = document.getElementById('canvas'); +var gl = canvas.getContext('webgl'); + +canvas.addEventListener('webglcontextrestored', function(e) { + console.log(e); +}, false); + +gl.getExtension('WEBGL_lose_context').restoreContext(); +</pre> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName('WEBGL_lose_context', "", "WEBGL_lose_context.loseContext")}}</td> + <td>{{Spec2('WEBGL_lose_context')}}</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.WEBGL_lose_context.restoreContext")}}</p> + +<h2 id="相关链接">相关链接</h2> + +<ul> + <li>{{domxref("WebGLRenderingContext.isContextLost()")}}</li> + <li>事件: <code><a href="/en-US/docs/Web/API/HTMLCanvasElement/webglcontextlost_event">webglcontextlost</a></code>, <code><a href="/en-US/docs/Web/API/HTMLCanvasElement/webglcontextrestored_event">webglcontextrestored</a></code>, <code><a href="/en-US/docs/Web/API/HTMLCanvasElement/webglcontextcreationerror_event">webglcontextcreationerror</a></code></li> +</ul> |