Display lists present a way to duplicate scene objects. They use a block structure such as the gl.Begin
and gl.End
function pairs. Almost every OpenGL call is stored into display list except those that manipulate with buffers and memory content. Display lists were intensively used and misused in the past to make scene rendering faster. However, they are now deprecated in relation to vertex buffers, which offer superior performance.
Before using the display list, you need to generate the display list object with the gl.GenLists(range)
function. This function accepts one argument that represents the number of continuous display lists to be generated. It returns an identifier of the first display list.
The included sample code will assume that the dl_id
variable contains a valid display list identifier.
The display list can be filled with instructions in a block that is enclosed by the gl.NewList
and gl.EndList
commands. The gl.NewList
function has this specification:
gl.NewList(display_list_identifier, mode)
There are two modes that the display list builder will work with:
The sample code with the usage of display lists is as follows:
gl.NewList(dl_id, gl_enum.GL_COMPILE) gl.Begin(gl_enum.GL_TRIANGLES) -- A gl.Color4f(1, 0, 0, 1) gl.Vertex3f(-0.5, -0.5, 0) -- B gl.Color4f(0, 1, 0, 1) gl.Vertex3f(0.5, -0.5, 0) -- C gl.Color4f(0, 0, 1, 1) gl.Vertex3f(0.5, 0.5, 0) gl.End() gl.EndList()
After this, you can execute the display list with the gl.CallList
or gl.CallLists
commands. These commands present a convenient way to call repetitive tasks with one command. The following example shows the usage of both functions:
gl.CallList(dl_id) gl.CallLists({dl_id, ...})
After you no longer need the display list, you have to delete the display list with the gl.DeleteLists(display_list_identifier, range)
function.
Display lists compile the entire command block for efficient execution. Games often use display list compilations during the loading screen, where it prepares all the important data for the gameplay.
Note that the display lists contain only command calls. You are allowed to do the nesting of display lists with the gl.CallList(another_display_list)
function call inside the display list, but the content of another display list is not transferred. Therefore, you can easily replace the content of the child display list.
Another thing is that, once the display list is compiled, you might only replace the whole display list content.
18.118.137.7