HTML and CSS Reference
In-Depth Information
WebGL provides a low-level API for generating 3-D scenes, relying on shader programs written in a special-
ized shader language called WebGL Shader Language (GLSL) that is based on C. Unless you have experience
writing GPU shaders, working with WebGL can be a little daunting to get started.
Luckily, a popular library called Three.js provides a high-level abstraction that enables you to start building
3-D in the browser without needing to worry about shaders. You can get Three.js and view a large number of
examples at http://mrdoob.github.com/three.js/ .
Although Three.js makes working with WebGL easier, 3-D programming can still be fairly complex.
Some projects exist to make developing with Three.js even easier. One of the most popular is tQuery: ht-
tp://jeromeetienne.github.com/tquery/ .
tQuery aims to provide a jQuery-like interface on top of Three.js to make it easier to start and work with 3-D
in the browser. Three.js also supports 3-D renderers other than WebGL, so some simple examples may run on
mobile devices, but more complicated examples require the WebGL renderer be used.
The main sticking point from a mobile standpoint is that only one mobile browser, Opera 12, has WebGL
enabled for general use. On the desktop every current-version browser except Internet Explorer has WebGL
support, including Firefox, Chrome, Safari, and Opera. Microsoft has unfortunately not committed to providing
support for WebGL at any point in the future, but given WebGL's popularity with developers, it seems a little
like browser-suicide for Microsoft to continue that position.
Although WebGL is not yet available in mobile Safari, it is already turned on in iAds, so support is built
in but disabled. If you have a jail-broken iPad, you can find resources to turn WebGL support back on. On
Android, WebGL pops up on various places, such as the Xperia smartphone and demos of the Xoom tablet, but
there's currently no timeline for support in Chrome for Android.
Getting Better Access to Sound with the
Web Audio API
As you saw in Chapter 25, “Playing Sounds, the Mobile Achilles' Heel,” sound in HTML5 on mobile devices is
not well supported. The good news is that an extremely rich Audio API called the Web Audio API has made its
way into the desktop versions of Chrome and Safari. The API can be a little daunting because it's low level but
feature rich and is something a game developer would be used to rather than a web developer. The most recent
published specification is available at www.w3.org/TR/webaudio .
If it gains wider browser support, the Web Audio API can provide a powerful audio layer for HTML5 games,
enabling real-time creation and mixing of effects and music via JavaScript.
As of this writing Apple has announced that iOS 6 will have support for the audio API, but what level of
support this will be and what restrictions will be placed on playing audio are yet to be determined. Because the
Web Audio API is a project that Google first implemented in Chrome, it appears likely that the API will make
its way into Chrome for Android in the near future.
As of this writing neither Microsoft, Mozilla, or Opera have announced any intention to support the API.
Search WWH ::




Custom Search