Game Development Reference
In-Depth Information
Chapter 7
OpenGL ES: A Gentle
Introduction
Mr. Nom was a great success. Due to its solid initial design and game framework, implementing
Mr. Nom was a breeze for us. Best of all, the game runs smoothly even on low-end devices. Of
course, Mr. Nom is not a very complex or graphically intense game, so using the Canvas API for
rendering proved to be a good idea.
However, when you want to do something more complex, you will hit a wall: Canvas just can't
keep up with the visual complexity of such a game. And if you want to go fancy-pants 3D,
Canvas won't help you either. So . . . what can you do?
This is where OpenGL ES comes to the rescue. In this chapter, first we'll look briefly at what
OpenGL ES actually is and does. We'll then focus on using OpenGL ES for 2D graphics without
having to dive into the more mathematically complex realms of using the API for 3D graphics
(we'll get to that in a later chapter). We'll take baby steps at first, as OpenGL ES can get quite
complicated. Are you ready to get introduced to OpenGL ES?
What Is OpenGL ES and Why Should I Care?
OpenGL ES is an industry standard for (3D) graphics programming. It is especially targeted at
mobile and embedded devices. It is maintained by the Khronos Group, which is an industry
consortium whose members include, among others, ATI, NVIDIA, and Intel; together, these
companies define and extend the standard.
Speaking of standards, there are currently four incremental versions of OpenGL ES: 1.0, 1.1,
2.0, and the recently released 3.0. We are concerned with the first two in this topic. All Android
devices support OpenGL ES 1.0, and most also support version 1.1, which adds some new
features to the 1.0 specification. OpenGL ES 2.0, however, breaks compatibility with the
1.x versions. You can use either 1.x or 2.0, but not both at the same time. The reason for this is
that the 1.x versions use a programming model called fixed-function pipeline , while version 2.0
lets you programmatically define parts of the rendering pipeline via so-called shaders . Many of
275
 
Search WWH ::




Custom Search