programming hints
OpenGL performance hints
state change
OpenGL state setting commands can be classified into two different categories. The first category is
glVertex glColor glIndex glNormal glEdgeFlag glMaterial glTexCoord
The processing of these calls is very fast. Restructuring a program to eliminate some vertex data commands will not significantly improve performance.
The second category is modal
•Turn on/off capabilities,
•Change attribute settings for capabilities,
•Define lights,
•Change matrices,
•etc.
These calls cannot occur between a glBegin/glEnd pair. Examples of such commands are:
glEnable(GL_LIGHTING); glFogf(GL_FOG_MODE, GL_LINEAR); glLightf(..); glLoadMatrixf(..);
Changes to the modal state are significantly more expensive to process than simple
Chapter 5 | 57 |