javascript - enable webGL automatically? -
i using glfx.js jquery plugin adjusting image's hue/saturation of browser not supporting webgl
is there way automatically enable webgl in browser if website uses it?
i know need enable manually in safari, , there plugin ie.
or there way can know @ time of page load webgl disabled ?
there isn't way automatically enable webgl in browser. it's in hands of browser vendor enable default - safari , ie 2 latecomers in area. webgl coming in ie11 (source), , imagine next release of safari have on default (it's been on year since last release).
you can detect if webgl enabled.
as you're aware, glfx.js spits out error message if webgl isn't enabled. sounds you're trying take other action if that's case (no webgl support).
looking @ glfx.js documentation, provide example:
window.onload = function() { // try create webgl canvas (will fail if webgl isn't supported) try { var canvas = fx.canvas(); } catch (e) { alert(e); // here want take other action // example, redirecting page window.location.href = ... return; } } for reading not using glfx.js, theeasiest check use !!window.webglrenderingcontext, doesn't work (some browsers throw false positives). best create canvas element , check webgl context:
function webglsupport() { var canvas = document.createelement( 'canvas' ); var webgl = false; try { webgl = !!( canvas.getcontext( 'webgl' ) || canvas.getcontext( 'experimental-webgl' ) ); } catch(e) {}; return webgl; }
Comments
Post a Comment