Questions about Display List OpenGL SC 1.0.1

163 Views Asked by At

I have several questions about the Display Lists in OpenGL SC 1.0.1:

  1. if I understand well, a display list saves a sequence of OpenGL primitives commands, to be reused after at runtime. Now, let's say that I also include in this Display List an assignment that changes the value of a parameter that was declared out of the static sequence. -> Would this parameter be updated, during the generation of the Display List, or when this Display List will be called at runtime ?

  2. I use to generate all my Display Lists at initialization of the OpenGL context only. But, in my application, for several reasons, I do glClear at each cycle at runtime. -> After a glClear command, do you think that all my Display Lists are deleted ? Because, by doing so, I notice that my graphical components that are generated through Display Lists are never drawn.

1

There are 1 best solutions below

2
robthebloke On

Display lists are created once, at exactly the point when you call glNewList. That list is then repeated verbatim when you call glCallList. I'm not sure what you mean by parameter exactly, but if you mean:

a) a C++ variable, then this will have no effect. The OpenGL calls in a display list are recorded as is. What loop variables etc used to get to that call are not recorded. b) an OpenGL state variable (for example, a call to enable GL_LIGHTING). This will be recorded (since the display list will capture the call to glEnable).

glClear has no effect on display lists. glClear simply clears the back buffer to black (or colour you set via glClearColor). Obviously once you've cleared all the pixel data, you'll need to redraw it again, so you'll need to set the projection matrix, set the correct transform matrix for your geometry in the display list, and call glCallList again to repeat the list of actions within that list.

Having said all of that, I'd strongly advise steering well clear of display lists, and move to something nicer (e.g. VBO + VAO + GLSL Shaders, or VBO + Fixed Function Pipeline). Display lists have a large number of problems, including:

  • They are a nightmare for driver maintainers. As a result, graphics card support for them is a little bit of a mixed bag.
  • Not all GL API methods are valid to be called within a display list. Some methods (such as those that modify the client state - e.g. vertex array bindings) simply do not work in display lists. Others don't work simply because the driver implementors decided to not add support (e.g. NVidia will allow some GL3+ methods to be called within a display list, AMD only allows methods from OpenGL 1.5).
  • Updating a display list is painfully slow.