[29852] | 1 | /**
|
---|
| 2 | * @author alteredq / http://alteredqualia.com/
|
---|
| 3 | * @author mr.doob / http://mrdoob.com/
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | var Detector = {
|
---|
| 7 |
|
---|
| 8 | canvas: !! window.CanvasRenderingContext2D,
|
---|
| 9 | webgl: ( function () { try { return !! window.WebGLRenderingContext && !! document.createElement( 'canvas' ).getContext( 'experimental-webgl' ); } catch( e ) { return false; } } )(),
|
---|
| 10 | workers: !! window.Worker,
|
---|
| 11 | fileapi: window.File && window.FileReader && window.FileList && window.Blob,
|
---|
| 12 |
|
---|
| 13 | getWebGLErrorMessage: function () {
|
---|
| 14 |
|
---|
| 15 | var element = document.createElement( 'div' );
|
---|
| 16 | element.id = 'webgl-error-message';
|
---|
| 17 | element.style.fontFamily = 'monospace';
|
---|
| 18 | element.style.fontSize = '13px';
|
---|
| 19 | element.style.fontWeight = 'normal';
|
---|
| 20 | element.style.textAlign = 'center';
|
---|
| 21 | element.style.background = '#fff';
|
---|
| 22 | element.style.color = '#000';
|
---|
| 23 | element.style.padding = '1.5em';
|
---|
| 24 | element.style.width = '400px';
|
---|
| 25 | element.style.margin = '5em auto 0';
|
---|
| 26 |
|
---|
| 27 | if ( ! this.webgl ) {
|
---|
| 28 |
|
---|
| 29 | element.innerHTML = window.WebGLRenderingContext ? [
|
---|
| 30 | 'Your graphics card does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">WebGL</a>.<br />',
|
---|
| 31 | 'Find out how to get it <a href="http://get.webgl.org/" style="color:#000">here</a>.'
|
---|
| 32 | ].join( '\n' ) : [
|
---|
| 33 | 'Your browser does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">WebGL</a>.<br/>',
|
---|
| 34 | 'Find out how to get it <a href="http://get.webgl.org/" style="color:#000">here</a>.'
|
---|
| 35 | ].join( '\n' );
|
---|
| 36 |
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | return element;
|
---|
| 40 |
|
---|
| 41 | },
|
---|
| 42 |
|
---|
| 43 | addGetWebGLMessage: function ( parameters ) {
|
---|
| 44 |
|
---|
| 45 | var parent, id, element;
|
---|
| 46 |
|
---|
| 47 | parameters = parameters || {};
|
---|
| 48 |
|
---|
| 49 | parent = parameters.parent !== undefined ? parameters.parent : document.body;
|
---|
| 50 | id = parameters.id !== undefined ? parameters.id : 'oldie';
|
---|
| 51 |
|
---|
| 52 | element = Detector.getWebGLErrorMessage();
|
---|
| 53 | element.id = id;
|
---|
| 54 |
|
---|
| 55 | parent.appendChild( element );
|
---|
| 56 |
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | }; |
---|