Files
BrainWind/app/src/lib/webgl-detect.ts
T

19 lines
453 B
TypeScript

let _webglSupported: boolean | null = null;
export function isWebGLSupported(): boolean {
if (_webglSupported !== null) return _webglSupported;
try {
const canvas = document.createElement('canvas');
const gl =
canvas.getContext('webgl2') ??
canvas.getContext('webgl') ??
canvas.getContext('experimental-webgl');
_webglSupported = gl !== null;
} catch {
_webglSupported = false;
}
return _webglSupported;
}