| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Global variable. | 5 // Global variables. |
| 6 var gl_context; | 6 var gl_context; |
| 7 var gl_renderer; |
| 7 | 8 |
| 8 initializeWebGL = function(canvas) { | 9 initializeWebGL = function(canvas) { |
| 9 gl_context = null; | 10 gl_context = null; |
| 10 // Try to grab the standard context. | 11 // Try to grab the standard context. |
| 11 gl_context = canvas.getContext("webgl") || | 12 gl_context = canvas.getContext("webgl") || |
| 12 canvas.getContext("experimental-webgl"); | 13 canvas.getContext("experimental-webgl"); |
| 13 // If we don't have a GL context, give up now. | 14 // If we don't have a GL context, give up now. |
| 14 if (!gl_context) { | 15 if (!gl_context) { |
| 15 err = "Unable to initialize WebGL. Your browser may not support it."; | 16 err = "Unable to initialize WebGL. Your browser may not support it."; |
| 16 if (domAutomationController) { | 17 if (window.domAutomationController) { |
| 17 console.log(err); | 18 console.log(err); |
| 18 } else { | 19 } else { |
| 19 alert(err); | 20 alert(err); |
| 20 } | 21 } |
| 21 } | 22 } |
| 22 } | 23 } |
| 23 | 24 |
| 24 startWebGLContext = function() { | 25 startWebGLContext = function() { |
| 25 var canvas = document.getElementById("glcanvas"); | 26 var canvas = document.getElementById("glcanvas"); |
| 26 // Initialize the GL context. | 27 // Initialize the GL context. |
| 27 initializeWebGL(canvas); | 28 initializeWebGL(canvas); |
| 28 | 29 |
| 29 // Only continue if WebGL is available and working. | 30 // Only continue if WebGL is available and working. |
| 30 if (gl_context) { | 31 if (gl_context) { |
| 31 gl_context.clearColor(0.0, 0.0, 0.0, 1.0); | 32 gl_context.clearColor(0.0, 0.0, 0.0, 1.0); |
| 32 gl_context.enable(gl_context.DEPTH_TEST); | 33 gl_context.enable(gl_context.DEPTH_TEST); |
| 33 gl_context.depthFunc(gl_context.LEQUAL); | 34 gl_context.depthFunc(gl_context.LEQUAL); |
| 34 gl_context.clearDepth(1); | 35 gl_context.clearDepth(1); |
| 35 gl_context.clear(gl_context.COLOR_BUFFER_BIT | | 36 gl_context.clear(gl_context.COLOR_BUFFER_BIT | |
| 36 gl_context.DEPTH_BUFFER_BIT); | 37 gl_context.DEPTH_BUFFER_BIT); |
| 38 |
| 39 // Also fetch the unmasked GL_RENDERER string. |
| 40 var ext = gl_context.getExtension("WEBGL_debug_renderer_info"); |
| 41 gl_renderer = gl_context.getParameter(ext.UNMASKED_RENDERER_WEBGL); |
| 37 } | 42 } |
| 38 | 43 |
| 39 domAutomationController.setAutomationId(0); | 44 if (window.domAutomationController) { |
| 40 domAutomationController.send("FINISHED"); | 45 domAutomationController.setAutomationId(0); |
| 46 domAutomationController.send("FINISHED"); |
| 47 } |
| 41 } | 48 } |
| OLD | NEW |