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