diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-01-07 16:03:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-07 16:03:28 +0100 |
commit | 57efe0bea5e60eb1849c9e42c89205996df819d5 (patch) | |
tree | 303d9260529b63d28ad4a76a7822c6e7a893c87c | |
parent | abcb87bc43672cdf0180505a4885677f52ca2f6f (diff) | |
parent | 2dbf8251bc2a3018890ad8c874cda44dcc6dbdc4 (diff) |
Merge pull request #15443 from eska014/html5-fixcanvas
Fix WebGL context initialization
-rw-r--r-- | platform/javascript/engine.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/platform/javascript/engine.js b/platform/javascript/engine.js index dc4bdc7efb..bca1851f40 100644 --- a/platform/javascript/engine.js +++ b/platform/javascript/engine.js @@ -138,13 +138,17 @@ } var actualCanvas = this.rtenv.canvas; - var context = false; + var testContext = false; + var testCanvas; try { - context = actualCanvas.getContext('webgl2') || actualCanvas.getContext('experimental-webgl2'); + testCanvas = document.createElement('canvas'); + testContext = testCanvas.getContext('webgl2') || testCanvas.getContext('experimental-webgl2'); } catch (e) {} - if (!context) { + if (!testContext) { throw new Error("WebGL 2 not available"); } + testCanvas = null; + testContext = null; // canvas can grab focus on click if (actualCanvas.tabIndex < 0) { |