Fix angle backend detection, though that should no longer be relevant
This commit is contained in:
parent
8c96e2fd90
commit
7ae3fb6109
@ -93,38 +93,46 @@ function detectBackend(str) {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function detectANGLEBackend(): AngleVersion {
|
function detectANGLEBackend(): AngleVersion {
|
||||||
const canvas = document.createElement("canvas");
|
try {
|
||||||
const gl = canvas.getContext("webgl2") ||
|
const canvas = document.createElement("canvas");
|
||||||
canvas.getContext("webgl") ||
|
const gl = canvas.getContext("webgl2") ||
|
||||||
canvas.getContext("experimental-webgl");
|
canvas.getContext("webgl") ||
|
||||||
|
canvas.getContext("experimental-webgl");
|
||||||
|
|
||||||
const ext = (gl as any).getExtension("WEBGL_debug_shaders");
|
if (!gl) {
|
||||||
|
return AngleVersion.NotAvailable;
|
||||||
if (!ext) {
|
|
||||||
return AngleVersion.NotAvailable;
|
|
||||||
}
|
|
||||||
|
|
||||||
const isWebGL1 = gl instanceof WebGLRenderingContext;
|
|
||||||
const shader = (gl as any).createShader((gl as any).VERTEX_SHADER);
|
|
||||||
|
|
||||||
(gl as any).shaderSource(
|
|
||||||
shader,
|
|
||||||
`#version ${isWebGL1 ? "100" : "300 es"}
|
|
||||||
void main() {
|
|
||||||
gl_Position = vec4(__VERSION__, 1.0, 1.0, 1.0);
|
|
||||||
}
|
}
|
||||||
`
|
|
||||||
);
|
|
||||||
|
|
||||||
(gl as any).compileShader(shader);
|
const ext = (gl as any).getExtension("WEBGL_debug_shaders");
|
||||||
|
|
||||||
if (!(gl as any).getShaderParameter(shader, (gl as any).COMPILE_STATUS)) {
|
if (!ext) {
|
||||||
console.error("invalid shader", (gl as any).getShaderInfoLog(shader));
|
return AngleVersion.NotAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
const isWebGL1 = gl instanceof WebGLRenderingContext;
|
||||||
|
const shader = (gl as any).createShader((gl as any).VERTEX_SHADER);
|
||||||
|
|
||||||
|
(gl as any).shaderSource(
|
||||||
|
shader,
|
||||||
|
`#version ${isWebGL1 ? "100" : "300 es"}
|
||||||
|
void main() {
|
||||||
|
gl_Position = vec4(__VERSION__, 1.0, 1.0, 1.0);
|
||||||
|
}
|
||||||
|
`
|
||||||
|
);
|
||||||
|
|
||||||
|
(gl as any).compileShader(shader);
|
||||||
|
|
||||||
|
if (!(gl as any).getShaderParameter(shader, (gl as any).COMPILE_STATUS)) {
|
||||||
|
console.error("invalid shader", (gl as any).getShaderInfoLog(shader));
|
||||||
|
return AngleVersion.NotAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
const source = ext.getTranslatedShaderSource(shader);
|
||||||
|
|
||||||
|
return detectBackend(source);
|
||||||
|
} catch (e) {
|
||||||
return AngleVersion.NotAvailable;
|
return AngleVersion.NotAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
const source = ext.getTranslatedShaderSource(shader);
|
|
||||||
|
|
||||||
return detectBackend(source);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user