PDA

View Full Version : Display Lists



ToddAtWSU
02-10-2006, 12:57 PM
I am trying to draw an object that consists of multiple polygons by storing the polygons into a display list. The object is read from a PLY file and stored into some arrays. I know I could display the object using vertex arrays, but I want to learn to use display lists, but I am having problems with the display lists. If I understand it correctly, I can only put OpenGL code into the list which would mean no loops in it, right? So what can I do to draw an unknown number of polygons until run time when I read the PLY file? I could do it using for-loops, but I cannot figure out how to dyamically build a display list. Thanks for your help!

dorbie
02-10-2006, 02:35 PM
No,

you can put loops inside the list etc. But only the OpenGL code will be 'recorded'. This does not mean the loops are ingored, the loops etc will run correctly and produce openGL commands and those commands will be stored to the display list, but only during 'recording'.

However when you subsequently call the list to the results at the time you recorded the display list will be reproduced exactly. In other words the code in the list is discarded, but the OpenGL results have been stored.

In other words, you can write a loop or execute code to help build a list, but if it's dependent on variables etc and those variables change after you create the list you will not see the changes reflected when you draw the list, the list will always look the same, only external state can affect a display list appearance once created.

Display lists are a convenient way of optimizing out slow code that generates vertices, you can take a long time to calculate the OpenGL values etc. and placing the code in a display list can be used to store only the resulting OpenGL command stream for efficient subsequent rendering.

ToddAtWSU
02-10-2006, 05:55 PM
Okay, so I can use a for-loop to set up reading my twenty-plus polygons and then just those polygons will be stored in the display list? I only use the variables to find specific vertices inside my arrays to know which vertices to connect for the polygon. Thanks for your help!