Skip to content

Commit 791b275

Browse files
authored
Merge pull request #953 from cwillisf/webgl-1-then-2
try WebGL 2.0 if WebGL 1.0 fails
2 parents 1569809 + 0f6663f commit 791b275

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/RenderWebGL.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,12 @@ class RenderWebGL extends EventEmitter {
111111
* @private
112112
*/
113113
static _getContext (canvas) {
114-
return twgl.getWebGLContext(canvas, {alpha: false, stencil: true, antialias: false});
114+
const contextAttribs = {alpha: false, stencil: true, antialias: false};
115+
// getWebGLContext = try WebGL 1.0 only
116+
// getContext = try WebGL 2.0 and if that doesn't work, try WebGL 1.0
117+
// getWebGLContext || getContext = try WebGL 1.0 and if that doesn't work, try WebGL 2.0
118+
return twgl.getWebGLContext(canvas, contextAttribs) ||
119+
twgl.getContext(canvas, contextAttribs);
115120
}
116121

117122
/**

0 commit comments

Comments
 (0)