programming hints
OpenGL performance hints
mode | Specifies the primitive or primitives that will be |
| created from the vertices. Ten symbolic constants are |
| accepted: GL_POINTS, GL_LINES, GL_LINE_STRIP, |
| GL_LINE_LOOP, GL_TRIANGLES, GL_TRIANGLE_STRIP, |
| GL_TRIANGLE_FAN, GL_QUADS, GL_QUAD_STRIP, and |
| GL_POLYGON. |
list | A sequence of starting indices in the enabled arrays. |
| Each index is the start of a primitive in the set. The |
| final value in the sequence indexes the end of the set. |
| The total number of indices is count+1. |
count | The number of primitives in the set to render. |
When glDrawArraySethp is called, it iterates over count + 1 vertex array indices from list. For 0 HP uses list[i+1] - list[i] sequential elements from each enabled array to construct a sequence of geometric primitives, beginning with element list[i].
Calling glDrawArraySethp(mode, list, count) is functionally equivalent to:
for (i = 0; i < count; i++)
glDrawArrays(mode, list[i], list[i+1]- list[i]);
textures
If calls to glTexImage are put into a display list, they may be cached. In general, for best performance, use Array Sets and Arrays, Display, and Immediate Mode (Vertex API). Note that if you are going to use the same texture multiple times, you may gain better performance if you put the texture in a display list. Another solution would be to use texture objects. Since 3D textures can potentially become very large, they are not cached.
state changes and their effects on display lists
If there are several state changes in a row, it is possible, in some circumstances, for the display list to optimize them.
It is more efficient to put a state change before a glBegin, than after it. For example, this is always more efficient:
glColor3f(1,2,3); glBegin(GL_TRIANGLES); glVertex3f(...);
54 | Chapter 5 |