HTML and CSS Reference
In-Depth Information
What Is WebGL?
WebGL is a JavaScript API that gives programmers access to the 3D hardware on the
user's machine. Currently, it is only supported by the debug/development versions of
Opera, Firefox, and Chrome. The API is managed by Kronos, the same organization
that manages OpenGL. In fact, much of WebGL is similar to programming in OpenGL.
This is both good and bad. It's good because it's a standard programming interface that
is recognizable to many developers, but bad because it is not as easy to learn as the 2D
Canvas context.
How Do I Test WebGL?
First, you need to find a web browser that supports WebGL. When trying to run a
WebGL application, a browser that does not support WebGL might give a message
like the one shown in Figure 11-1 .
Figure 11-1. Trying to run WebGL in a standard web browser
Chromium, the open source version of Chrome, will display WebGL.
You can download the latest development build of Chromium from
http://build.chromium.org/f/chromium/continuous/ .
Once you have a browser that can display WebGL, you need to write the code to make
it happen. You start that process by accessing the WebGL context instead of the Canvas
2d context. So, instead of this code, which we have used throughout this topic:
context = theCanvas.getContext("2d");
We reference the experimental-webgl context, like this:
gl = theCanvas.getContext("experimental-webgl");
 
Search WWH ::




Custom Search