1/** 2 * Detects if WebGL is enabled. 3 * Inspired from http://www.browserleaks.com/webgl#howto-detect-webgl 4 * 5 * @return { number } -1 for not Supported, 6 * 0 for disabled 7 * 1 for enabled 8 */ 9function detectWebGL() 10{ 11 // Check for the WebGL rendering context 12 if ( !! window.WebGLRenderingContext) { 13 var canvas = document.createElement("canvas"), 14 names = ["webgl", "experimental-webgl", "moz-webgl", "webkit-3d"], 15 context = false; 16 17 for (var i in names) { 18 try { 19 context = canvas.getContext(names[i]); 20 if (context && typeof context.getParameter === "function") { 21 // WebGL is enabled. 22 return 1; 23 } 24 } catch (e) {} 25 } 26 27 // WebGL is supported, but disabled. 28 return 0; 29 } 30 31 // WebGL not supported. 32 return -1; 33} 34 35function isSet(foo) { 36 if(typeof(foo) !== 'undefined') { 37 return true; 38 } else { 39 return false; 40 } 41}
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.