PDA

View Full Version : GL_TRIANGLE_STRIP vs. GL_TRIANGLES



jframosr
09-11-2003, 01:31 AM
Hi people!
I am going crazy! the following has no sense, but I can confirm is true: I have this code:

for(i=0;i<this->lStripsD.num;i++) {
glBegin(GL_TRIANGLE_STRIP);
for (it = this->lStripsD[i].begin(); it != this->lStripsD[i].end(); ++it) {
v=*it;
x=this->lVerts[v].x; y=this->lVerts[v].y; z=this->lVerts[v].z;
glVertex3f(x,y,z);
}
glEnd();
}

and another version with the same mesh but using GL_TRIANGLE draws it in less time...

with GL_TRIANGLE_STRIP I send 7190 vertex with all the stripes, and with GL_TRIANGLES I send 17412 vertexs, how is it posible?


Thansk for your help!!!

GPSnoopy
09-11-2003, 01:50 AM
You're CPU limited because you're doing everything in immediate mode using glVertex(). Your triangle code is probably less CPU intensive than your triangle strip code, which explains the worse performance of the latter.

I suggest you use display lists and/or vertex arrays. (and if you want to go even further, use vertex buffer objects).

jframosr
09-11-2003, 01:57 AM
with display lists the performance is worse, it is not applicable to my problem because the mesh changes dynamically...

Anyway thanks a lot!
F.

GPSnoopy
09-11-2003, 09:21 AM
Originally posted by jframosr:
it is not applicable to my problem because the mesh changes dynamically...

VBOs are *THE* answer then.
But you should try simple vertex arrays first if you're not used to them yet, you should already get an impressive boost in performance with these anyway.