1/** 2 * @author alteredq / http://alteredqualia.com/ 3 * @author mr.doob / http://mrdoob.com/ 4 */ 5 6var WEBGL = { 7 isWebGLAvailable: function () { 8 try { 9 var canvas = document.createElement( 'canvas' ); 10 return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) ); 11 } catch ( e ) { 12 return false; 13 } 14 }, 15 isWebGL2Available: function () { 16 try { 17 var canvas = document.createElement( 'canvas' ); 18 return !! ( window.WebGL2RenderingContext && canvas.getContext( 'webgl2' ) ); 19 } catch ( e ) { 20 return false; 21 } 22 }, 23 getWebGLErrorMessage: function () { 24 return this.getErrorMessage( 1 ); 25 }, 26 getWebGL2ErrorMessage: function () { 27 return this.getErrorMessage( 2 ); 28 }, 29 getErrorMessage: function ( version ) { 30 var names = { 31 1: 'WebGL', 32 2: 'WebGL 2' 33 }; 34 var contexts = { 35 1: window.WebGLRenderingContext, 36 2: window.WebGL2RenderingContext 37 }; 38 var message = 'Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>'; 39 var element = document.createElement( 'div' ); 40 element.id = 'webglmessage'; 41 element.style.fontFamily = 'monospace'; 42 element.style.fontSize = '13px'; 43 element.style.fontWeight = 'normal'; 44 element.style.textAlign = 'center'; 45 element.style.background = '#fff'; 46 element.style.color = '#000'; 47 element.style.padding = '1.5em'; 48 element.style.width = '400px'; 49 element.style.margin = '5em auto 0'; 50 if ( contexts[ version ] ) { 51 message = message.replace( '$0', 'graphics card' ); 52 } else { 53 message = message.replace( '$0', 'browser' ); 54 } 55 message = message.replace( '$1', names[ version ] ); 56 element.innerHTML = message; 57 return element; 58 } 59}; 60//export { WEBGL };
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.