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
3// found in the LICENSE file.
4
5// Global variable.
6var gl_context;
7
8initializeWebGL = function(canvas) {
9  gl_context = null;
10  // Try to grab the standard context.
11  gl_context = canvas.getContext("webgl") ||
12               canvas.getContext("experimental-webgl");
13  // If we don't have a GL context, give up now
14  if (!gl_context) {
15    alert("Unable to initialize WebGL. Your browser may not support it.");
16  }
17}
18
19startWebGLContext = function() {
20  var canvas = document.getElementById("glcanvas");
21  // Initialize the GL context.
22  initializeWebGL(canvas);
23
24  // Only continue if WebGL is available and working.
25  if (gl_context) {
26    gl_context.clearColor(0.0, 0.0, 0.0, 1.0);
27    gl_context.enable(gl_context.DEPTH_TEST);
28    gl_context.depthFunc(gl_context.LEQUAL);
29    gl_context.clearDepth(1);
30    gl_context.clear(gl_context.COLOR_BUFFER_BIT |
31                     gl_context.DEPTH_BUFFER_BIT);
32  }
33}