“Everyone knows that if you want to do cross-platform hardware-accelerated 3D graphics on your desktop, you use OpenGL. If you ask the same for the web, there hasn’t been a good answer. WebGL will hopefully fix that, taking advantage of the ubiquity and popularity of OpenGL in a way that fits the web,” he wrote last month. “The WebGL working group is targeting the first half of 2010 for release of the standard.”

Users and developers can now begin testing Mozilla’s WebGL support by downloading the latest nightly builds and toggling the webgl.enabled_for_all_sites property in about:config. After I set that property, I was able to use WebGL using Minefield on Mac OS X. Instructions are available from Vukicevic’s blog. Linux and Windows are supported too, but some Windows users may need to download an extra DLL and enable software rendering if they don’t have up-to-date OpenGL drivers or 3D-enabled hardware. Vukicevic says that Mozilla might eventually explore solutions like building a Direct3D backend to provide native Windows support.

In a follow-up post featured at the Mozilla Hacks website, he shows how WebGL can be used to display a COLLADA model. Specifically, he uses a critter exported from the popular video game Spore. His demo displays the 3D model in a Canvas element and allows the user to rotate by clicking and dragging. A quick glance at the page source code provides some insight into how WebGL works. In the sporeview.js file, Canvas event listeners detect when the user clicks and moves the mouse so that the model can be rotate as the user drags. The Spore model, which is in the XML-based COLLADA format, is loaded with an XMLHttpRequest in the SporeFile.js script. The OpenGL shader language is used inside of HTML script tags that are referenced by ID in the JavaScript code. It’s fascinating to see how the underlying concepts of OpenGL programming have been adapted for the Web.