--- 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 ---
WEBGL_lose_context.restoreContext() 属于 WebGL API。 , 一般用来模拟 {{domxref("WebGLRenderingContext")}} 的上下文恢复。
gl.getExtension('WEBGL_lose_context').restoreContext();
INVALID_OPERATION
上下文尚未丢失你可以用这个方法模拟 webglcontextrestored
事件:
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();
Specification | Status | Comment |
---|---|---|
{{SpecName('WEBGL_lose_context', "", "WEBGL_lose_context.loseContext")}} | {{Spec2('WEBGL_lose_context')}} | Initial definition. |
The compatibility table in 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.
{{Compat("api.WEBGL_lose_context.restoreContext")}}
webglcontextlost
, webglcontextrestored
, webglcontextcreationerror