PDA

View Full Version : Speed of creating a display list each frame.



dalangalma
08-06-2004, 05:52 AM
I have an object that may change shape each frame (a dynamic heightfield). It's got a hefty number of polygons, and I need to draw it quite a few times each frame. Would my application get faster or slower if I created a display list of the heightfield first, then called the display list multiple times? The way I see it, it might get faster because I'm not re-drawing and re-sending all the information so many times per frame, but it might get slower because I'm generating a display list each frame.

Relic
08-06-2004, 07:35 AM
If things change per frame it's probably better to put your geometry inside a vertex array, draw the geometry with indexed methods (glDrawElements, glDrawRangeElements), and use vertex buffer objects on top of that to get better performance.
The index array will always remain the same if only the heights change. You only need to transfer the part of the vertex data which actually changes.
There's another method with vertex programs which take two attributes, the grid positions in a 2D attribute array and the height in a single attribute array which changes, and the vertex programs combines these to a 3D position.

dalangalma
08-06-2004, 09:17 AM
Won't I still be transferring the vertex information however many times per frame?

Korval
08-06-2004, 10:50 AM
A display list is a very heavyweight object. Building one takes a non-trivial amount of time; moreso than just uploading some data to the card. It would be better to use a streaming VBO than to keep rebuilding a display list. Indeed, it probably be faster to use immediate mode than to keep rebuilding the display list.

Humus
08-06-2004, 11:56 AM
Originally posted by dalangalma:
Won't I still be transferring the vertex information however many times per frame?Not if you're uploading it to a VBO. Then you're only transferring it once. Be aware though when using VBOs that you avoid resizing the buffer, otherwise you may end up losing performance instead. Allocate once, then update with glBufferSubDataARB() rather than glBufferDataARB() to avoid forcing the driver to resize the buffer.

Kilam Malik
08-08-2004, 11:44 PM
I'm using the same technique: Making a display list each frame for a changing object and then draw it many times.
The difference to your heighfield is, that my display list only consists of 8 triangles and I draw the list 100 times then for each frame.
In my case, I got a speedup, but I think that for your big heightfield the VBO should be the better solution.

Kilam.