CPEN 461/661, Spring 1997
OpenGL Tutorial

  1. Display Lists
  2. A display list is a group of OpenGL commands that have been stored for later execution. When a display list is invoked, the commands in it are executed in the order in which they were issued.

    One common use is creating a display list for an object that is to be drawn more than once. If the vertices of the object must be calculated, then the calculations need only be performed rather than each time the object is drawn.

    The commands glNewList(GLuint name, GLenum mode) and glEndList() are used to begin and end the definition of a display list. The argument name is an integer index that uniquely defines the display list. The argument mode specifies the compilation mode, which can be GL_COMPILE, specifying that the following commands not be executed as they are stored in the display list, or GL_COMPILE_AND_EXECUTE, specifying that the commands be executed as they are stored in the display list.

    After a display list is created, it can be executed by the command glCallList(GLuint name).



    Polygons_List.c Source Code

    This example is a modification Polygons.c to use display lists.



    Circle_List.c Output



    Circle_List.c Source Code

    Notice that there are non-OpenGL commands within the definition of the display list for the circle. These commands are executed only once, when the display is created, and are not stored in the display list. Only a certain subset of the OpenGL commands can be stored in a display list. For a more detailed discussion of display lists, refer to Section 5.4 Display Lists of the OpenGL Specification.