try WebGL 2.0 if WebGL 1.0 fails

This commit is contained in:
Christopher Willis-Ford 2021-10-26 14:20:36 -07:00
parent 156980980f
commit 0f6663f314

View file

@ -111,7 +111,12 @@ class RenderWebGL extends EventEmitter {
* @private
*/
static _getContext (canvas) {
return twgl.getWebGLContext(canvas, {alpha: false, stencil: true, antialias: false});
const contextAttribs = {alpha: false, stencil: true, antialias: false};
// getWebGLContext = try WebGL 1.0 only
// getContext = try WebGL 2.0 and if that doesn't work, try WebGL 1.0
// getWebGLContext || getContext = try WebGL 1.0 and if that doesn't work, try WebGL 2.0
return twgl.getWebGLContext(canvas, contextAttribs) ||
twgl.getContext(canvas, contextAttribs);
}
/**