You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
Check only for WebGL 1.0, move test to HTML file
Whether to use WebGL 1.0 or 2.0 can only be determined at runtime after reading project settings, so check for the lower version. The test is now in the HTML file, so if desired WebGL 2.0 can be checked early by changing the behaviour there.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user