Please send me your comments
Display Lists Tutorial


Without Display Lists
Creating a DL
The Greedy Approach
Using Nested Display Lists
Other Considerations

Visual C++ project

[Previous: Creating a DL] [Next: Using Nested Display Lists]

The greedy approach

At this point you may be thinking, "Lets put all the code inside a single display list". First of all note that there are some commands that can't be placed inside a Display List, these are:

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);

	for(int i = -3; i < 3; i++)
		for(int j=-3; j < 3; j++) {
			glTranslatef(i*10.0,0,j * 10.0);


The function to render the scene is:

void renderScene(void) {

// Draw ground

	glColor3f(0.9f, 0.9f, 0.9f);
		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);

// Draw 36 SnowMen



The approximate number of fps for this version is 108. There was a significant loss in performance when the main loop was included in the display list.

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]

Site designed and maintained by António Ramires Fernandes
Your comments, suggestions and references to further material are welcome!