10
Chapter
OpenGL ES 2, Shaders,
and...
Her angel’s face, As the great eye of heaven shined bright, And made a
sunshine in the shady place.
-----Edmund Spenser
There are two different versions of the OpenGL ES graphics library on your iOS devices.
This book has largely dealt with the higher-level one, known as OpenGL ES 1,
sometimes referred to as 1.1 or 1.x. The second version is a rather confusingly named
OpenGL ES 2. The first one is by far the easier of the two; it comes with all sorts of
helper libraries doing much of the 3D mathematics and all of the lighting, coloring, and
shading on your behalf. ES 2 eschews all of those niceties and is sometimes referred to
as the ‘‘programmable function’’ version (vs. ES 1’s ‘‘fixed function’’ design, which is
generally sneered at by the true pixel-jockeys who prefer more control over their
imagery, usually for immersive 3D game environments where every little visual footnote
is emphasized). For that, OpenGL ES 2 was released.
In this chapter, we’ll just touch ever so briefly on shaders, just enough to give you a
general feel for them. Afterward, I’ll go into some more of the GLKit goodness not
covered in previous chapters.
Version 1 is relatively close to the desktop variety of OpenGL, making porting
applications, particularly vintage ones, a little less painful than having a badger gnaw
your face off. The things that were left out were done so to keep the footprint small on
limited-resource devices and to ensure performance was as good as could be.
Version 2 defenestrated compatibility altogether and concentrated on performance and
flexibility-oriented features aimed primarily at entertainment-oriented software. Among
the things left out were glRotatef(), glTranslatef(), matrix stack operations, and so
on. But what we got in return are some delightful little morsels such as a programmable
pipeline via the use of shaders. And the loss of the transformation methods have been