|
|
glColorPointer | glDeleteLists | glDisableClientState |
glEdgeFlagPointer | glEnableClientState | glFeedBackBuffer |
glFinish | glFlush | glGenLists |
glGet* | glIndexPointer | glInterleavedArrays |
glIsEnabled | glIsList | glNormalPointer |
glPixelStore | glReadPixels | glRenderMode |
glSelectBuffer | glTexCoordPointer | glVertexPointer |
Placing any of the above commands in a Display List causes them to be immediately executed.
The entire loop to design the snowman has been placed in the Display List. The code to create the display list is now:
GLuint createDL() {
GLuint snowManDL;
snowManDL = glGenLists(1);
glNewList(snowManDL,GL_COMPILE);
for(int i = -3; i < 3; i++)
for(int j=-3; j < 3; j++) {
glPushMatrix();
glTranslatef(i*10.0,0,j * 10.0);
drawSnowMan();
glPopMatrix();
}
glEndList();
return(snowManDL);
}
void renderScene(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Draw ground
glColor3f(0.9f, 0.9f, 0.9f);
glBegin(GL_QUADS);
glVertex3f(-100.0f, 0.0f, -100.0f);
glVertex3f(-100.0f, 0.0f, 100.0f);
glVertex3f( 100.0f, 0.0f, 100.0f);
glVertex3f( 100.0f, 0.0f, -100.0f);
glEnd();
// Draw 36 SnowMen
glCallList(DLid);
glutSwapBuffers();
}
The full source code is available here.
Although we added more commands to the display list we did suffered a performance penalty because the size of the list is much larger now and therefore the memory transfer hurts the performance.
As with almost everything else size does matter! A Display List that is too small may cause a performance hit because the penalty involved in calling the list may be bigger than the advantage of the preprocessing of the commands contained inside it. For very large lists there may be also a penalty due to the memory transfer.
[Previous: Creating a DL] | [Next: Using Nested Display Lists] |