webglcontextrestored
event of the
WebGL API
is fired if the user agent restores the drawing buffer for a
WebGLRenderingContext
对象。
Once the context is restored, WebGL resources such as textures and buffers that were created before the context was lost are no longer valid. You need to reinitialize the state of your WebGL application and recreate resources.
| 冒泡 | Yes |
|---|---|
| 可取消 | Yes |
| 接口 |
WebGLContextEvent
|
| 事件处理程序特性 | none |
With the help of the
WEBGL_lose_context
extension, you can simulate the
webglcontextrestored
event:
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();
// "webglcontextrestored" event is logged.
| 规范 | 状态 | 注释 |
|---|---|---|
|
WebGL 1.0
The definition of 'webglcontextrestored' in that specification. |
推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
webglcontextrestored
event
|
Chrome 9 | Edge 12 | Firefox 4 | IE 11 | Opera 12 | Safari 5.1 | WebView Android Yes | Chrome Android 25 | Firefox Android 4 | Opera Android 12 | Safari iOS 8 | Samsung Internet Android 1.5 |
完整支持
WebGLContextEvent
WebGLRenderingContext.isContextLost()
WEBGL_lose_context
,
WEBGL_lose_context.loseContext()
,
WEBGL_lose_context.restoreContext()