Detecting-WebGL-and-browser-compatibility.html 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <base href="../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. <h1>[name]</h1><br />
  12. <p>
  13. Even those this is becming less and less of a problem, some devices or browsers may not support WebGL.
  14. Here is how to check if it is supported and display a warning to the user if it is not.
  15. </p>
  16. <h2>A solution</h2>
  17. <p>In order to detect webgl compatibility and gracefully inform the user you can add <a href="https://github.com/mrdoob/three.js/blob/master/examples/js/Detector.js">https://github.com/mrdoob/three.js/blob/master/examples/js/Detector.js</a> to your javascript and use this example to avoid even attempting to render anything:</p>
  18. <pre><code>if (Detector.webgl) {
  19. init();
  20. animate();
  21. } else {
  22. var warning = Detector.getWebGLErrorMessage();
  23. document.getElementById('container').appendChild(warning);
  24. }
  25. </code></pre>
  26. </body>
  27. </html>