CS405 Lab 6: Display Lists and Basic Buffers


Highlights of this lab:

This lab is an introduction to Display Lists and Animation

Assignment:

Online OpenGL Manual


Seminar Notes

A. Creating, Recording and Executing a Display List

The limited commands that are acceptable between a glBegin() / glEnd() pair only describe an OpenGL primitive. Therefore if you are going to repeatedly execute the same sequence of OpenGL commands, you can create and store a display list and then have this cached sequence of calls repeated with minimal overhead, since all of the vertices, lighting calculations, textures, and matrix operations stored in that list are calculated only when the list is created, not when it is replayed.

Creating a display list is very simple. Let's suppose that we have some code that creates a static model. The important part of the code is within the glBegin() / glEnd() pair. The function for the stock scene looks like this:

    // start rendering the stock scene
    glBegin (GL_POLYGON);
       ... ... details
    // finish rendering the stock scene
    glEnd ();

A display list records the results of a glBegin() / glEnd() sequence. When you record a display list, the current state is used to create the display list; when the list ends, the current state is whatever the original state was, plus any changes made during the recording of the displaying list. Replaying the display list uses the current state, not the state that was in effect when the list was recorded. When the replay ends, the current state is the state when the replay started plus any any changes to the state that were replayed as part of the display list.

To use a display list you will need to use the following commands: