views:

204

answers:

2

I'm developing an application which make use of display lists offered by OpenGL. My idea is to call display lists for a repeatitive tasks, such as tranformations and server state sets. Actually the implementation allow two display lists per renderable object. In these two cases display lists doesn't contains vertices, normals etc., but only matrices and server states.

My problem now is how to decide when generate a display list: it could happen, in some cases, the properties which have generated a display list changes, causing a new compilation of the display list (think a mouse move which rotate an object).

It could be appropriate to generate a display list only when properties are not changed in N rendering loops? How to quantify this N? Should I disable temporarly specific display lists?

Note: the source could be found at Renderable (187:201) and at RenderState (315:356). Sorry for identation (I think it's my VS...) I've notice only right now. :(

OT: how to reformat only identation? :)

+5  A: 

To be honest, I'd recommend against using Display Lists. They've been deprecated by the OpenGL standard. Instead, you should use vertex buffers (check out glDrawArrays or glDrawElements).

Then, you don't have to worry about regenerating your display lists, just setting up your arrays of vertices.

Jesse Beder
+1 Display Lists are slow, obsolete and just complicate things...
Nils Pipenbrinck
I already use buffer objects. In a OpenGL 3 only implementation the display list management could be excluded, but on most cards the display lists allow to avoid a lots of PInvoke; additionally display lists cache commands and data efficiently, increasing rendering performances (precompute inverse matrices during lighting, for example).
Luca
Have you tested that you actually get a performance increase? It depends on an awful lot of things; and also, you could (and probably should, if you're interested in performance) precompute and store the lighting matrices yourself.
Jesse Beder
Drawing the same simple scene (a chessboard) 100 times each frame , the application takes 3,31 secs without display lists; while enabling display lists takes 2,74 secs, resulting faster the 15% (and application uses display lists only for two server states)
Luca
A: 

Keep in mind that the answer doesn't take into account whether use or not use display lists. (edit: display list can be used on older systems, and could improve performances on those systems).

The N quantity should be proportional to data quantity stored into the display list. Display list recompilation shall be done just when data contained into display list changes, but if data changes frequently the recompilation process could be delayed untill stable data is verified.

Luca