Open GL Super Bible

Previous Table of Contents Next


Reference Section

glCallList

Purpose
Executes a display list.
Include File
<gl.h>
Syntax
void glCallList(GLuint list);
Description
Executes the display list identified by list. The OpenGL State Machine is not restored after this function is called, so it is a good idea to call glPushMatrix beforehand and glPopMatrix afterwards. Calls to glCallList may be nested. The function glGet with the argument GL_MAX_LIST_NESTING returns the maximum number of allowable nests. For Microsoft Windows, this value is 64.

Parameters

list
GLuint: Identifies the display list to be executed.
Returns
None.

Example

The following code saves the matrix state before calling a display list. It then restores the state afterwards. This code is from the BOLTL example program from this chapter’s subdirectory on the CD.

    // Save the current transform state
    glPushMatrix();

    // Draw the bolt including nested display lists
    glCallList(BOLT_HEAD);

    // Restore state
   glPopMatrix();
See Also
glCallLists, glDeleteLists, glGenLists, glNewList

glCallLists

Purpose
Executes a list of display lists.
Include File
<gl.h>
Syntax
void glCallLists(GLsizei n, GLenum type, const GLvoid *lists);
Description
This function calls the display lists listed in the *lists array sequentially. This array can be of nearly any data type. The result is converted or clamped to the nearest integer value to determine the actual index of the display list. Optionally, the list values can be offset by a value specified by the function glListBase.

Parameters

n
GLsizei: Number of elements in the array of display lists.
type
GLenum: Specifies the datatype of the array stored at *lists. This can be any one of the following values: GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT, GL_INT, GL_UNSIGNED_INT, GL_FLOAT, GL_2_BYTES, GL_3_BYTES, and GL_4_BYTES.
*lists
GLvoid: An array of elements of the type specified in type. The data type is void to allow any of the above data types to be used.
Returns
None.

Example

The following code shows how to call a list of display lists with a single call:

    // Storage for the display list identifiers
    int lists[50];
    int i;
     …
     …
    // Create list names
    for(i = 0; i < 50; i++)
            lists[i] = i+1;

    // Build some fifty display lists //////////
    // First list
    glNewList(lists[0],GL_COMPILE);
            …
            …
    glEndList();

    // Second list
    glNewList(lists[1],GL_COMPILE);
           …
           …
    glEndList();

    // And so on …
     …
     …

    // Call all fifty lists with a single call
    glCallLists(50, GL_INT, lists);
See Also
glCallList, glDeleteLists, glGenLists, glListBase, glNewList

glDeleteLists

Purpose
Deletes a continuous range of display lists.
Include File
<gl.h>
Syntax
void glDeleteLists(GLuint list, GLsizei range);
Description
This function deletes a range of display lists. The range goes from an initial value and proceeds until the number of lists deleted as specified by range is completed. Deleting unused display lists can save considerable memory. Unused display lists in the range of those specified are ignored and do not cause an error.

Parameters

list
GLuint: The integer name of the first display list to delete.
range
GLsizei: The number of display lists to be deleted following the initially specified list.
Returns
None.

Example

The following single line of code shows any and all display lists with identifiers between 1 and 50 being deleted:

    glDeleteLists(1, 50);
See Also
glCallList, glCallLists, glGenLists, glIsList, glNewList

glEndList

Purpose
Delimits the end of a display list.
Include File
<gl.h>
Syntax
void glEndList( void);
Description
Display lists are created by first calling glNewList. Thereafter, all OpenGL commands are compiled and placed in the display list. The glEndList function terminates the creation of this display list.
Returns
None.

Example

The following example code shows an example of a display list being delimited by glNewList and glEndList. This particular display list is composed by nesting two other display lists within it.

    // Begin delimit of list
    glNewList(BOLT_LIST,GL_COMPILE);

           // Display list calls two previously defined display lists
           glCallList(SHAFT_LIST);
           glCallList(THREAD_LIST);

    // End this display list
    glEndList();
See Also
glCallList, glCallLists, glDeleteLists, glGenLists, glIsList


Previous Table of Contents Next