Skip to content

Instantly share code, notes, and snippets.

@godismyjudge95
Created February 20, 2019 19:46
Show Gist options
  • Save godismyjudge95/f9b77d238e6580ca10303947add3f4b9 to your computer and use it in GitHub Desktop.
Save godismyjudge95/f9b77d238e6580ca10303947add3f4b9 to your computer and use it in GitHub Desktop.
Detecting gl properly in modern browsers
var canvas = document.createElement("canvas");
try { gl = canvas.getContext("webgl"); }
catch (x) { gl = null; }
if (gl == null) {
try { gl = canvas.getContext("experimental-webgl"); experimental = true; }
catch (x) { gl = null; }
}
gl = !!gl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment