Contents /
Previous /
Next
Hierarchical Display Lists
You can create a hierarchical display list, which is a display list that
executes another display list by calling glCallList() between a glNewList() and
glEndList() pair. A hierarchical display list is useful for an object made of
components, especially if some of those components are used more than once. For
example, this is a display list that renders a bicycle by calling other display
lists to render parts of the bicycle:
glNewList(listIndex,GL_COMPILE);
glCallList(handlebars);
glCallList(frame);
glTranslatef(1.0,0.0,0.0);
glCallList(wheel);
glTranslatef(3.0,0.0,0.0);
glCallList(wheel);
glEndList();
To avoid infinite recursion, there's a limit on the nesting level of display
lists; the limit is at least 64, but it might be higher, depending on the
implementation. To determine the nesting limit for your implementation of
OpenGL, call
glGetIntegerv(GL_MAX_LIST_NESTING, GLint *data);
OpenGL allows you to create a display list that calls another list that hasn't
been created yet. Nothing happens when the first list calls the second,
undefined one.