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 variable. |
6 var gl_context; | 6 var gl_context; |
7 | 7 |
8 initializeWebGL = function(canvas) { | 8 initializeWebGL = function(canvas) { |
9 gl_context = null; | 9 gl_context = null; |
10 // Try to grab the standard context. | 10 // Try to grab the standard context. |
11 gl_context = canvas.getContext("webgl") || | 11 gl_context = canvas.getContext("webgl") || |
12 canvas.getContext("experimental-webgl"); | 12 canvas.getContext("experimental-webgl"); |
13 // If we don't have a GL context, give up now | 13 // If we don't have a GL context, give up now. |
14 if (!gl_context) { | 14 if (!gl_context) { |
15 alert("Unable to initialize WebGL. Your browser may not support it."); | 15 err = "Unable to initialize WebGL. Your browser may not support it."; |
| 16 if (domAutomationController) { |
| 17 console.log(err); |
| 18 } else { |
| 19 alert(err); |
| 20 } |
16 } | 21 } |
17 } | 22 } |
18 | 23 |
19 startWebGLContext = function() { | 24 startWebGLContext = function() { |
20 var canvas = document.getElementById("glcanvas"); | 25 var canvas = document.getElementById("glcanvas"); |
21 // Initialize the GL context. | 26 // Initialize the GL context. |
22 initializeWebGL(canvas); | 27 initializeWebGL(canvas); |
23 | 28 |
24 // Only continue if WebGL is available and working. | 29 // Only continue if WebGL is available and working. |
25 if (gl_context) { | 30 if (gl_context) { |
26 gl_context.clearColor(0.0, 0.0, 0.0, 1.0); | 31 gl_context.clearColor(0.0, 0.0, 0.0, 1.0); |
27 gl_context.enable(gl_context.DEPTH_TEST); | 32 gl_context.enable(gl_context.DEPTH_TEST); |
28 gl_context.depthFunc(gl_context.LEQUAL); | 33 gl_context.depthFunc(gl_context.LEQUAL); |
29 gl_context.clearDepth(1); | 34 gl_context.clearDepth(1); |
30 gl_context.clear(gl_context.COLOR_BUFFER_BIT | | 35 gl_context.clear(gl_context.COLOR_BUFFER_BIT | |
31 gl_context.DEPTH_BUFFER_BIT); | 36 gl_context.DEPTH_BUFFER_BIT); |
32 } | 37 } |
33 } | 38 |
| 39 domAutomationController.setAutomationId(0); |
| 40 domAutomationController.send("FINISHED"); |
| 41 } |
OLD | NEW |