1

IE11 バージョン 11.0.9600.16428 以下では、一部の WebGL メソッドが正しく機能していません (ここで説明されているように: https://github.com/mrdoob/three.js/issues/3600 )

一例はメソッドclearStencilです。問題は、メソッドが存在することですが、正しく機能していません。それを検出して、ユーザーにフィードバックを提供したいと思います。Three.js の Detector.js を試してみましたが、ブラウザーとグラフィック カードが WebGL をサポートしているかどうかのみがチェックされ、関連するすべての機能がサポートされているかどうかはチェックされません。

次のような WebGL チェックを実行しようとしました。

var supportsWebGL=function(){
    if(Detector.webgl){
        var _canvas = document.createElement( 'canvas' );
        var _gl = _canvas.getContext( 'webgl' ) || _canvas.getContext( 'experimental-webgl' );
        try{
            _gl.clearStencil( 0 );
        }catch(e){
            return false;
        }
        return true;
    }else{
        return false;
    }
}

IE11 (11.0.9600.16428) では、メソッドsupportsWebGLは true を返しますが、次のようなエラーが表示されます。

WEBGL11095: INVALID-OPERATION: clearStencil: メソッドは現在サポートされていません。

ここで、メソッドsupportsWebGLがその非互換性を検出して false を返すようにします。誰もそれを行う方法を知っていますか?

4

2 に答える 2

3

I found a way to do this by using _gl.getError()

var supportsWebGL=function(){
    if(Detector.webgl){
        var _canvas = document.createElement( 'canvas' );
        var _gl = _canvas.getContext( 'webgl' ) || _canvas.getContext( 'experimental-webgl' );
        var errors=undefined;        
        try{
            _gl.clearStencil( 0 );
            errors=_gl.getError();
        }catch(e){
            return false;
        }
        return errors==0;
    }else{
        return false;
    }
}

Only if errors are equal to zero the method will return true. If you have other methods you want to check for, just add them to the try/catch block.

If you need a solution that works without Three.js, check this out:

var supportsWebGL=function(){
    if(!window.WebGLRenderingContext)return false;
    try{
        var _canvas = document.createElement( 'canvas' );
        var _gl = _canvas.getContext( 'webgl' ) || _canvas.getContext( 'experimental-webgl' );
        _gl.clearStencil( 0 );
        var errors=_gl.getError();
        return errors==0;
    }catch(e){
        return false;
    }
}
于 2015-02-10T12:13:28.003 に答える