Pro OpenGL ES for iOS

(singke) #1

Chapter 9


Performance ’n’ Stuff


An ounce of performance is worth pounds of promises.

------M a e W e s t

I'm so fast that last night I turned off the light switch in my hotel room
and was in bed before the room was dark.

------M u h a m m a d A l i

When dealing with 3D worlds, performance is nearly always an issue because of the
intensive mathematics required for even simple scenes. If all you want to render is a
bouncing cube, then not to worry, but if you want to display the universe, you’ll always
be concerned about performance.


Up until now, the exercises have been presented in a way to be reasonably clear (I hope)
but not necessarily efficient. And unfortunately, efficient code is rarely the clearest and
most easily understood. So now, we’re going to start looking at the slightly messier stuff
and see how it can be integrated into your applications.


In its manual on OpenGL ES, Apple has a section called ‘‘Best Practices.’’ I’ll cover
those in detail in this chapter followed by a look at some of the tools Apple provides
developers specifically for analyzing and debugging OpenGL programs.


Vertex Buffer Objects

The two main arenas of performance enhancements are minimizing the data transfer to
and from the graphics hardware and minimizing data itself. Vertex buffer objects (VBOs)
are part of the former process. When you generated your geometry and sent it merrily
along to be displayed, the usual process was to tell the system where to find each of the
needed blocks of data, enabling which data to use (vertex, normals, colors, and texture
coordinates) and then drawing it. Each time glDrawArrays() or glDrawElements() is
called, all of the data must be packed up and shipped to the graphics processing unit

Free download pdf