Pro OpenGL ES for iOS

(singke) #1

CHAPTER 9: Performance ’n’ Stuff (^295)
Figure 9-2. Performance Detective
Interleaved Data
Another recommended trick is to use interleaved data as opposed to sequential arrays.
Remember the example from Chapter 8 when creating the stellar importer? There’s not
much difference here. You can take the individual buffers and weave them together so
that each vertex’s data is in one contiguous structure, as shown in Figure 9-3.
Figure 9-3. Data ordering. The VBO example uses the top format, while the bottom illustrates data interleaving.
In my own tests I found the difference to be negligible. But still, keep interleaving in mind
for your projects, and it can’t hurt to design for it because future hardware might make
better use of it.
Batching
Batch as many operations as possible that rely on the same state, because changing
the system state (by using the glEnable() and glDisable() calls) is costly. OpenGL
does not check internally to see whether a specific feature is already in the state you
want. In the exercises in this book, I would frequently set states more often than I likely

Free download pdf