Title: OpenGL Display Lists
1OpenGL Display Lists
- A way to improve performance.
2Why Use Display Lists
- May improve performance.
- You can define the geometry and/or state changes
once and execute them multiple times. - Download remotely to reduce network overhead.
- Even locally, you can reduce overhead by storing
frequently used commands.
3EXAMPLE
- Consider a Tricycle.
- Two same sized wheels.
- Offset from one another.
- One larger wheel.
- Also offset.
- Use ONE wheel description in a display list and
execute the list three times.
4OpenGL Code
GLuint theTorus theTorus glGenLists(1) glNewLi
st(theTorus, GL_COMPILE) torus(8,25) / draw
the torus / glEndList() . . . (and in display
function) glClear(GL_COLOR_BUFFER_BIT) glColor3f(
1.0, 1.0, 1.0) glCallList(theTorus) glFlush()
5OpenGL Code
GLuint theTorus theTorus glGenLists(1) glNewLi
st(theTorus, GL_COMPILE) torus(8,25) / draw
the torus / glEndList() . . . (and in display
function) glClear(GL_COLOR_BUFFER_BIT) glColor3f(
1.0, 1.0, 1.0) glCallList(theTorus) glFlush()
6OpenGL Code
GLuint theTorus theTorus glGenLists(1) glNewLi
st(theTorus, GL_COMPILE) torus(8,25) / draw
the torus / glEndList() . . . (and in display
function) glClear(GL_COLOR_BUFFER_BIT) glColor3f(
1.0, 1.0, 1.0) glCallList(theTorus) glFlush()
7OpenGL Code
GLuint theTorus theTorus glGenLists(1) glNewLi
st(theTorus, GL_COMPILE) torus(8,25) / draw
the torus / glEndList() . . . (and in display
function) glClear(GL_COLOR_BUFFER_BIT) glColor3f(
1.0, 1.0, 1.0) glCallList(theTorus) glFlush()
8OpenGL Code
GLuint theTorus theTorus glGenLists(1) glNewLi
st(theTorus, GL_COMPILE) torus(8,25) / draw
the torus / glEndList() . . . (and in display
function) glClear(GL_COLOR_BUFFER_BIT) glColor3f(
1.0, 1.0, 1.0) glCallList(theTorus) glFlush()
9Not Guaranteed
- Although youre not guaranteed that your OpenGL
implementation optimizes display lists for any
particular uses, executing display lists is no
slower than executing the commands contained
within them individually. - There is some overhead in jumping to a display
list.
10Optimization Possibilities
- Matrix Operations. Compute both the matrix and
its inverse and store in a display list. - Raster bitmaps and images. Transform the data
into a representation preferred by the hardware
and store in a display list. - Lights, Material Properties, and Lighting Models.
Put material definitions in a display list. - Polygon stipple patterns.
11Store State Settings with Geometry
glNewList(1, GL_COMPILE) glLoadMatrix(M) Draw_so
me_geometric_objects() glEndList() glCallList(1
)
glNewList(1, GL_COMPILE) Draw_some_geometric_obje
cts() glEndList() glLoadMatrix(M) glCallList(1
)
12Whats Stored in a Display List
- Only the values for expressions.
- If values in an array are subsequently changed,
the display list values DONT change!
13Cannot Be Stored
- glAreTexturesResident()
- glClientActiveTexture()
- glColorPointer()
- glDeleteLists()
- glDeleteTextures()
- glDisableClientState()
- glEdgeFlagPointer()
- glEnableClientState()
- glFeedbackBuffer()
- glFinish()
- glFlush()
- glFogCoordPointer()
- glGenLists()
- glGenTextures()
- glGet()
- glIndexPointer()
- glInterleavedArrays()
- glIsEnabled()
- glIsList()
- glIsTexture()
- glNormalPointer()
- glPixelStore()
- glPopClientAttribute()
- glPushClientAttribute()
- glReadPixels()
- glRenderMode()
- glSecondaryColorPointer()
- glSelectBuffer()
- glTexCoordPointer()
- glVertexPointer()
14Hierarchical Display Lists
- A list that executes another display list by
calling glCallList() between a glNewList() and
glEndList() pair. - A default limit to the nesting level of 64.
- glGetIntegerv(GL_MAX_LIST_NESTING, GLint
data) (for your implementation)
15Redbook Examples