OpenGL Display Lists - PowerPoint PPT Presentation

About This Presentation
Title:

OpenGL Display Lists

Description:

You can define the geometry and/or state changes once and execute ... Consider a Tricycle. Two same sized wheels. Offset from one another. One larger wheel. ... – PowerPoint PPT presentation

Number of Views:193
Avg rating:3.0/5.0
Slides: 16
Provided by: csMon
Category:

less

Transcript and Presenter's Notes

Title: OpenGL Display Lists


1
OpenGL Display Lists
  • A way to improve performance.

2
Why 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.

3
EXAMPLE
  • 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.

4
OpenGL 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()
5
OpenGL 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()
6
OpenGL 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()
7
OpenGL 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()
8
OpenGL 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()
9
Not 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.

10
Optimization 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.

11
Store 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
)
12
Whats Stored in a Display List
  • Only the values for expressions.
  • If values in an array are subsequently changed,
    the display list values DONT change!

13
Cannot 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()

14
Hierarchical 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)

15
Redbook Examples
  • torus.c
  • list.c
  • stroke.c
Write a Comment
User Comments (0)
About PowerShow.com