GL Primitives, texturing, and speed

Started by
3 comments, last by OrangyTang 15 years, 10 months ago
Hey guys, this is is more of a theoretical question than anything to do with something I'm currently trying to code, but I will definitely be taking the answer into consideration in the future. OK, first off, how big of a difference is there in drawing time between things like triangles, triangle strips and fans, quads, etc. What I mean is, I know I can draw any quad as a combination of triangles, but is drawing 2 triangles faster than drawing a single quad? I assume the triangle strips and fans are faster than triangle lists as well since it doesn't have to read in as many points into memory. Also, how would one use triangle strips and fans with texturing? Since you have to specify a texture coordinate for each point, using a strip or fan would seem to indicate that you'd need to put in TWO coordinates for each vertex. Also what if you want to use multiple textures within the same strip or fan, is that possible? I hope my questions are clear, if not please ask and I will try to clarify. Thanks!
Advertisement
Quads will be internally split into two triangles, so the drawing speed should be identical. Be careful because in some situations the automatic conversion can yield unexpected results (particularly with texture coord interpolation) so you might prefer to do this step manually.

Yup, strips and fans let you specify geometry without sending as many points. Graphics cards also have a post-transform cache which reuses vertices rather than transforming them each time which saves calculations. Since the vertices are shared that means the texture coords are shared too - usually this isn't a problem as they represent a continuous surface. If you want different texture coords you'll have to add extra vertices or split things up into separate strips. You can't change texture in the middle of a strip or fan either, so you have to split them up then too. Alternatively you can pack multiple textures into one bigger texture (like a sprite sheet or texture atlas) so you don't have to break up your strips.

Fans are pretty much useless since most geometry isn't fan-like. Strips are used much less now - it's usually preferable to use index geometry which gives you the same speed advantages without the awkward step of trying to strip-ify your model data.
Do most videocards handle the quad->tri splitting, or is it done by the driver?
Thanks for the reply!

Unfortunately the program I have in mind would need to change textures for every quad so looks like strips and fans are out. Oh well, there won't be enough to matter in this case, but its good to know for the future. Thanks again.
Changing texture every quad is going to kill your performance if you're not careful. You should look into using a texture atlas or sprite sheet so you can reduce the number of times you have to switch texture and so draw more stuff at once.

This topic is closed to new replies.

Advertisement