Tuesday, November 27th, 2007
When Ben and I gave our latest State of Ajax talk we wanted to show off Canvas 3D. We saw the “moz-gles11” context for Firefox 3, but at the time you had to build that bad boy from source. Riiight.
Over the past few months I’ve been able to do some much-needed code cleanup and put together a preview of what an OpenGL context for canvas could look like.
There are two contexts provided by the extension. “moz-gles11” follows the OpenGL ES 1.1 spec very closely, providing an almost identical API and feature set, and “moz-glweb20” follows OpenGL ES 2.0 closely. Both are implemented directly on top of desktop OpenGL, so you must have support for at least OpenGL 1.5 on the desktop for the “moz-gles11” context and OpenGL 2.0 for the “moz-glweb20” context.
OpenGL was chosen as the base API for a number of reasons. It is a standardized, proven cross-platform API. 3D is a complex subject, and providing a fully-featured API will allow developers to create libraries and toolkits to abstract away the complexity in ways that are specific to their application, without being tied into a specific approach. Using a standard API also allows us to leverage the vast developer base out there who have OpenGL knowledge. OpenGL ES is also the standard for 3D on mobile devices, ensuring that any 3D content will be able to migrate to mobile devices as the web becomes more and more featureful on such devices.
The difficulty with using OpenGL is that the API is not very approachable for web developers; it’s a huge jump going from the 2D canvas API to a full 3D API. My hope is that those developers who are familiar with OpenGL will be able to create helper libraries to make 3D content and manipulation more accessible, much like there are tools such as photo montage scripts that authors can use without having to understand the implementation details. Scene graphs and other frameworks would also provide great fodder for the performance improvement work going on as part of ES4.
I hope to propose the new API to an appropriate standards group after people have had an opportunity to play with the features and provide feedback on the initial implementation. As the core of the API is already a standard, a spec would only need to be written for the specific GL-Web integration points.
Posted by Dion Almaer at 7:31 am