From 0f6663f3148b4f994d58e19590e14c152f1cc2f8 Mon Sep 17 00:00:00 2001
From: Christopher Willis-Ford <7019101+cwillisf@users.noreply.github.com>
Date: Tue, 26 Oct 2021 14:20:36 -0700
Subject: [PATCH] try WebGL 2.0 if WebGL 1.0 fails

---
 src/RenderWebGL.js | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/RenderWebGL.js b/src/RenderWebGL.js
index d3694cc8..c65e6747 100644
--- a/src/RenderWebGL.js
+++ b/src/RenderWebGL.js
@@ -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);
     }
 
     /**