HTML and CSS Reference
What Is WebGL?
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
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
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");