1/** 2 * @author alteredq / http://alteredqualia.com/ 3 * @author mr.doob / http://mrdoob.com/ 4 */ 5 6var WEBGL = { 7 8 isWebGLAvailable: function () { 9 10 try { 11 12 var canvas = document.createElement( 'canvas' ); 13 return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) ); 14 15 } catch ( e ) { 16 17 return false; 18 19 } 20 21 }, 22 23 isWebGL2Available: function () { 24 25 try { 26 27 var canvas = document.createElement( 'canvas' ); 28 return !! ( window.WebGL2RenderingContext && canvas.getContext( 'webgl2' ) ); 29 30 } catch ( e ) { 31 32 return false; 33 34 } 35 36 }, 37 38 getWebGLErrorMessage: function () { 39 40 return this.getErrorMessage( 1 ); 41 42 }, 43 44 getWebGL2ErrorMessage: function () { 45 46 return this.getErrorMessage( 2 ); 47 48 }, 49 50 getErrorMessage: function ( version ) { 51 52 var names = { 53 1: 'WebGL', 54 2: 'WebGL 2' 55 }; 56 57 var contexts = { 58 1: window.WebGLRenderingContext, 59 2: window.WebGL2RenderingContext 60 }; 61 62 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>'; 63 64 var element = document.createElement( 'div' ); 65 element.id = 'webglmessage'; 66 element.style.fontFamily = 'monospace'; 67 element.style.fontSize = '13px'; 68 element.style.fontWeight = 'normal'; 69 element.style.textAlign = 'center'; 70 element.style.background = '#fff'; 71 element.style.color = '#000'; 72 element.style.padding = '1.5em'; 73 element.style.width = '400px'; 74 element.style.margin = '5em auto 0'; 75 76 if ( contexts[ version ] ) { 77 78 message = message.replace( '$0', 'graphics card' ); 79 80 } else { 81 82 message = message.replace( '$0', 'browser' ); 83 84 } 85 86 message = message.replace( '$1', names[ version ] ); 87 88 element.innerHTML = message; 89 90 return element; 91 92 } 93 94};
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.