60 WebGLUtils =
function() {
68 var makeFailHTML =
function(msg) {
70 '<table style="background-color: #8CE; width: 100%; height: 100%;"><tr>' +
71 '<td align="center">' +
72 '<div style="display: table-cell; vertical-align: middle;">' +
73 '<div style="">' + msg +
'</div>' +
82 var GET_A_WEBGL_BROWSER =
'' +
83 'This page requires a browser that supports WebGL.<br/>' +
84 '<a href="http://get.webgl.org">Click here to upgrade your browser.</a>';
90 var OTHER_PROBLEM =
'' +
91 "It doesn't appear your computer can support WebGL.<br/>" +
92 '<a href="http://get.webgl.org/troubleshooting/">Click here for more information.</a>';
106 var setupWebGL =
function(canvas, opt_attribs, opt_onError) {
107 function handleCreationError(msg) {
108 var container = canvas.parentNode;
110 var str = window.WebGLRenderingContext ?
114 str +=
"<br/><br/>Status: " + msg;
116 container.innerHTML = makeFailHTML(str);
120 opt_onError = opt_onError || handleCreationError;
122 if (canvas.addEventListener) {
123 canvas.addEventListener(
"webglcontextcreationerror",
function(event) {
124 opt_onError(event.statusMessage);
127 var context = create3DContext(canvas, opt_attribs);
129 if (!window.WebGLRenderingContext) {
142 var create3DContext =
function(canvas, opt_attribs) {
143 var names = [
"webgl",
"experimental-webgl",
"webkit-3d",
"moz-webgl"];
145 for (var ii = 0; ii < names.length; ++ii) {
147 context = canvas.getContext(names[ii], opt_attribs);
157 create3DContext: create3DContext,
158 setupWebGL: setupWebGL
165 window.requestAnimFrame = (
function() {
166 return window.requestAnimationFrame ||
167 window.webkitRequestAnimationFrame ||
168 window.mozRequestAnimationFrame ||
169 window.oRequestAnimationFrame ||
170 window.msRequestAnimationFrame ||
171 function( callback, element) {
172 window.setTimeout(callback, 1000/60);