Game Development Reference
In-Depth Information
the second-generation devices already support OpenGL ES 2.0; however, the cognitive friction
of both learning 3D programming and doing so with shaders is quite high. OpenGL ES 1.x is
more than good enough for most games though, so we will stick to it here. OpenGL ES 3.0 is so
fresh that at the time of writting, there's no device that implements the standard yet. It will take a
while for device manufacturers to get up to speed.
Note The emulator supports OpenGL ES 1.0 and 2.0. However, the emulation is not perfect. Also,
while OpenGL ES is a standard, different manufacturers interpret it differently and performance
across devices varies greatly, so make sure to test on a variety of devices to ensure compatibility.
We'll devise a couple of helpful classes that will work on any device.
OpenGL ES is an API that comes in the form of a set of C header files provided by the Khronos
Group, along with a very detailed specification of how the API defined in those headers should
behave. This includes things such as how pixels and lines have to be rendered. Hardware
manufacturers then take this specification and implement it for their GPUs on top of the GPU
drivers. You can find all the specifications and more at http://www.khronos.org/opengles .
The quality of these implementations varies slightly: some companies strictly adhere to the
standard (PowerVR), while others seem to have difficulty sticking to it. This can sometimes result
in GPU-dependent bugs in the implementation that have nothing to do with Android itself, but
with the hardware drivers provided by the manufacturers. We'll point out any device-specific
issues for you along your journey into OpenGL ES land.
Note OpenGL ES is more or less a sibling of the more feature-rich desktop OpenGL standard.
It deviates from the latter in that some of the functionality is reduced or completely removed.
Nevertheless, it is possible to write an application that can run with both specifications, which is
great if you want to port your game to your desktop as well.
So what does OpenGL ES actually do? The short answer is that it's a lean and mean triangle-
rendering machine. The long answer is a little bit more involved.
The Programming Model: An Analogy
Generally speaking, OpenGL ES is a 3D graphics programming API. As such, it has a pretty nice
and easy-to-understand programming model that we can illustrate with a simple analogy.
Think of OpenGL ES as working like a camera. To take a picture, you have to go to the scene
you want to photograph. Your scene is composed of objects—say, a table with more objects on
it. They all have a position and orientation relative to your camera as well as different materials
and textures. Glass is translucent and reflective; a table is probably made out of wood; a
magazine has the latest photo of a politician on it; and so on. Some of the objects might even
move around (for example, a fruit fly). Your camera also has properties, such as focal length,
 
Search WWH ::




Custom Search