Proper way to detect WebGL support?

后端 未结 7 1097
悲&欢浪女
悲&欢浪女 2020-11-30 05:15

I am attempting to detect WebGL support across multiple browsers and I\'ve encountered the following scenario. The current version of Firefox appears to report positive supp

相关标签:
7条回答
  • 2020-11-30 06:13

    The excellent Three library has, in fact, a mechanism for detecting the following:

    1. WebGL support
    2. File API support
    3. Workers support

    For WebGL, particularly, here is the code that is used:

    function webgl_support () { 
       try {
        var canvas = document.createElement('canvas'); 
        return !!window.WebGLRenderingContext &&
          (canvas.getContext('webgl') || canvas.getContext('experimental-webgl'));
       } catch(e) {
         return false;
       }
     };
    

    That code snippet is part of a Detector class which may also display the corresponding error messages to the user.

    0 讨论(0)
提交回复
热议问题