Skip to content

Commit

Permalink
WebGLRenderer: Listen to webglcontextcreationerror event. (mrdoob#24091)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob authored and abernier committed Sep 16, 2022
1 parent 0c1a84a commit 1fcb8c5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ function WebGLRenderer( parameters = {} ) {
// event listeners must be registered before WebGL context is created, see #12753
_canvas.addEventListener( 'webglcontextlost', onContextLost, false );
_canvas.addEventListener( 'webglcontextrestored', onContextRestore, false );
_canvas.addEventListener( 'webglcontextcreationerror', onContextCreationError, false );

if ( _gl === null ) {

Expand Down Expand Up @@ -593,6 +594,7 @@ function WebGLRenderer( parameters = {} ) {

_canvas.removeEventListener( 'webglcontextlost', onContextLost, false );
_canvas.removeEventListener( 'webglcontextrestored', onContextRestore, false );
_canvas.removeEventListener( 'webglcontextcreationerror', onContextCreationError, false );

renderLists.dispose();
renderStates.dispose();
Expand Down Expand Up @@ -653,6 +655,12 @@ function WebGLRenderer( parameters = {} ) {

}

function onContextCreationError( event ) {

console.error( 'THREE.WebGLRenderer: A WebGL context could not be created. Reason: ', event.statusMessage );

}

function onMaterialDispose( event ) {

const material = event.target;
Expand Down

0 comments on commit 1fcb8c5

Please sign in to comment.