0

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.

genpfault
  • 51,148
  • 11
  • 85
  • 139
LudoDu31
  • 31
  • 4

1 Answers1

0

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.
robthebloke
  • 9,331
  • 9
  • 12
  • For you point a): I fact, in my sequence for some reasons, at one point I have an IF... ELSE condition, depending on a parameter. And the OpenGL commands calls are different depending on such a condition: let's say command A or command B. So, I know that this parameter is at TRUE during the sequence. However, I think it is at FALSE when this sequence is called. Do you think command A or B would be called ? – LudoDu31 Oct 02 '19 at 10:52
  • About glClear: you mean, even if the command glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT) is called at each cycle, the display lists, with their index will be kept ? About your suggestion to use VBO + VAO + GLSL Shaders, or VBO + Fixed Function Pipeline instead of Display Lists: do you think this is usable for SC 1.0.1 ? Finally, about the methods that cannot be called within a Display List: what do you think would be the behaviour on target, if one of such methods are in a Display List ? A crash ? Nothing displayed ? – LudoDu31 Oct 02 '19 at 10:53