The webglcontextrestored
event of the WebGL API is fired if the user agent restores the drawing buffer for a WebGLRenderingContext
object.
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.
Bubbles | Yes |
Cancelable | Yes |
Interface | WebGLContextEvent
|
Event handler property | none |
Example
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.
Specifications
Specification | Status | Comment |
WebGL 1.0The definition of 'webglcontextrestored' in that specification. | Recommendation | Initial definition. |
Browser compatibility
The compatibility table on 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.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
webglcontextrestored event
|
Chrome
Full support 9 |
Edge
Full support 12 |
Firefox
Full support 4 |
IE
Full support 11 |
Opera
Full support 12 |
Safari
Full support 5.1 |
WebView Android
Full support Yes |
Chrome Android
Full support 25 |
Firefox Android
Full support 4 |
Opera Android
Full support 12 |
Safari iOS
Full support 8 |
Samsung Internet Android
Full support 1.5 |
Legend
- Full support
- Full support
See also
WebGLContextEvent
WebGLRenderingContext.isContextLost()
WEBGL_lose_context
,WEBGL_lose_context.loseContext()
,WEBGL_lose_context.restoreContext()
HTMLCanvasElement: webglcontextrestored event by Mozilla Contributors is licensed under CC-BY-SA 2.5.