Skip to content

Commit 0028db6

Browse files
committed
Add a method to detect webGL support
1 parent 9ccd77d commit 0028db6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/helpers.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,16 @@ export function createProgram(
5858
export function r(num: number) {
5959
return Math.round(num * 100) / 100;
6060
}
61+
62+
export function isWebGLSupported() {
63+
try {
64+
const canvas = document.createElement('canvas');
65+
return (
66+
!!window.WebGLRenderingContext &&
67+
(canvas.getContext('webgl') ||
68+
canvas.getContext('experimental-webgl'))
69+
);
70+
} catch (e) {
71+
return false;
72+
}
73+
}

0 commit comments

Comments
 (0)