diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-03-15 08:55:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-15 08:55:14 +0100 |
commit | 506c4926577910230eceecd07df3cc42e423d25f (patch) | |
tree | 5b5d883fe1e3997c494b5da21fe7352b343d501a /platform/javascript/engine.js | |
parent | 955397dfd5845c0bd1510581a77d20989f13ab19 (diff) | |
parent | 61026e62bf8659a4ffe4fc1b5cbd404d3e25adeb (diff) |
Merge pull request #17520 from eska014/wasm-webgl1
Check only for WebGL 1.0 before starting downloads, move test to HTML file
Diffstat (limited to 'platform/javascript/engine.js')
-rw-r--r-- | platform/javascript/engine.js | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/platform/javascript/engine.js b/platform/javascript/engine.js index bca1851f40..8f22e41660 100644 --- a/platform/javascript/engine.js +++ b/platform/javascript/engine.js @@ -138,18 +138,6 @@ } var actualCanvas = this.rtenv.canvas; - var testContext = false; - var testCanvas; - try { - testCanvas = document.createElement('canvas'); - testContext = testCanvas.getContext('webgl2') || testCanvas.getContext('experimental-webgl2'); - } catch (e) {} - if (!testContext) { - throw new Error("WebGL 2 not available"); - } - testCanvas = null; - testContext = null; - // canvas can grab focus on click if (actualCanvas.tabIndex < 0) { actualCanvas.tabIndex = 0; @@ -273,6 +261,20 @@ Engine.RuntimeEnvironment = engine.RuntimeEnvironment; + Engine.isWebGLAvailable = function(majorVersion = 1) { + + var testContext = false; + try { + var testCanvas = document.createElement('canvas'); + if (majorVersion === 1) { + testContext = testCanvas.getContext('webgl') || testCanvas.getContet('experimental-webgl'); + } else if (majorVersion === 2) { + testContext = testCanvas.getContext('webgl2') || testCanvas.getContet('experimental-webgl2'); + } + } catch (e) {} + return !!testContext; + }; + Engine.load = function(newBasePath) { if (newBasePath !== undefined) basePath = getBasePath(newBasePath); |