Nested display lists vs. duplicated

Hello,

Suppose you have a complex object to draw, like a computer case. You need to be able to show some components selected so you need keep objects separated.

Would you:

  1. create a display list for components and one display list for the case THAT CALLS single objects one

or:

  1. create a display list for components and one display list for the case that DOES NOT CALL single object ones

I mean, is there any benefit (to maximize speed) in duplicating the data on the GPU here? Or calling a number of display lists inside a main one is the same for the performance point of view?

I learned about Hierarchical Display Lists here: https://www.glprogramming.com/red/chapter07.html

Thanks,

Alberto

Note that display lists are “legacy” OpenGL. They don’t exist in OpenGL 3.2+ core profile or OpenGL ES. They aren’t necessarily efficient on modern hardware, as their intended use case doesn’t really apply to PCs. Their main use case was to minimise network bandwidth for indirect rendering on SGI Unix/X11 systems.

With modern OpenGL, to enable and disable parts of the scene you’d typically either use glMultiDrawElements, or use multiple glDrawElements calls for sub-ranges, or modify the element (index) array. But depending upon the effect you wish to use to indicate selection, you might just draw everything and have the shader program vary the rendering based upon selection status (communicated via a vertex attribute or a uniform array or similar).

For display lists, I’d probably create three lists for each object: one for the unselected object, one for the selected object, and a third which just calls either of the first two. The top-level list for the scene would call the third list for each object. Selection and deselection would change the third so it calls either the first or second.

For learning OpenGL, I’d suggest getting a recent version of the red book that covers modern OpenGL (version 4). The link is to the second edition, which covers OpenGL 1.1 and is essentially ancient history at this point.

Thanks GClements,

With modern OpenGL, to enable and disable parts of the scene you’d typically either use glMultiDrawElements , or use multiple glDrawElements calls for sub-ranges, or modify the element (index) array.

Do you know a code sample that renders a red cube with a blue face using this approach?

Thanks,

Alberto