Hello,
what’s is the better/faster method to draw several filled triangle based 3d-objects with OpenGL and Jogl in particular:
- to use glVertexPointer and then glDrawElements (or such), so that OpenGL fetches the geometric data from the main memory
- to use OpenGL-Displaylists? For example:
// p1x, p1x, p1y
int idx = o.glGenLists(1);
glNewList(idx, GL_COMPILE);
glBegin(GL_TRIANGLES),
glVertex3f(p1x, p1y, p1z);
glVertex3f(p2x, p2y, p2z);
glVertex3f(p3y, p3y, p3z);
// and so on for all vertices
o.glEnd();
o.glEndList();
The OpenGL Redbook manual says in Chapter 7:
Although you’re not guaranteed that your OpenGL implementation optimizes display lists for any particular uses, the execution of display lists isn’t slower than executing the commands contained within them individually. There is some overhead, however, involved in jumping to a display list. If a particular list is small, this overhead could exceed any execution advantage.
<<<
When scanning some OpenGL forums there are pretty contrary statements on this topic.
Personally I’d clearly prefer the Displaylist method.
First, it looks cleaner to me: the OpenGL implementation may transfer and optimize all neccessary geometric data for the list to its hardware (=server), so it’s away from the slow main memory/system (=client) which needn’t care about it - aside one nice index number to adress/draw it later.
Second, as a programmer, a platform independant Java programmer in particular, I don’t have to fiddle with “optimal” data structures in main memory, or to care about (silly!) pointers and that like. I give the geometric data from pretty handy (but not optimal) data structures to the display list once at the beginning and voila: fire and forget.
-ric