Jump to content
  • Advertisement
Sign in to follow this  
Polyphemus

OpenGL Triangles, quads, or both?

This topic is 4452 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Until now, I have always worked with triangles in my OpenGL programs. All quad geometry got converted to two triangles, and every object is drawn to the screen at once using vertex arrays. Now, I've been wondering for a while if it is the most efficient to do things this way. Probably, the triangles render a little faster than quads (do two triangles render faster than one quad?), but how about memory use? Is it worth to keep part of the geometry in quads, and where needed in triangles (drawing the object would be drawn in two times - triangles and quads), or is there such a performance drop which can't win from the memory savings. I found some threads about triangles vs quads, but not one about performance / memory use / result comparison. I would really appreciate your help. Thanks in advance, - Polyphemus

Share this post


Link to post
Share on other sites
Advertisement
Two triangles probably won't render faster than 1 quad, but one triangle strip will, AFAIK. Assuming your video card doesn't convert quads to triangles anyways, in which case it's a mute question.

If done right, you use the same number of vertices to render 1 triangle strip (of 2 triangles) as you do for a quad. As long as you draw the vertices in the right order (TL,BL,TR,BR for CCW), you can use the same vertex array to draw a quad or tristrip, and see if there's a speed difference for yourself.

Of course, all that's assuming you meant "converted to two triangles" literally, as in 2 seperate triangles of 3 vertices each, which is not the best way to do it. Rendering 2 seperate triangles would probably be slightly slower, for obvious reasons.

Share this post


Link to post
Share on other sites
Thanks for your reply. This brings me to a slightly off-topic question: I'm not an expert on sorting geometry, so does anyone know a good algorithm to convert geometry of single triangles to a triangle strip?

Edit: sorry, should've used Google ;). However, feel free to give your opinion about the best algorithms ;).

Share this post


Link to post
Share on other sites
Quote:
Original post by Prgrmr@wrk
Two triangles probably won't render faster than 1 quad, but one triangle strip will, AFAIK.


1 quad == 1 triangle strip. There is no difference in speed

Quote:
so does anyone know a good algorithm to convert geometry of single triangles to a triangle strip?


just use the nvidia tri-stripping library. Life's too short to worry about re-inventing an offline geometry processing technique..... ;)

In all honesty though, if your tri's are in indexed vertex buffers, then there is next to no difference in speed between a tri strip and a list of triangles. The only measurable difference in speed comes in transferring the indices to the graphics card. Tri-strips give the benefit of a smaller memory foot-print since they require fewer indices, but that's basically it. The computation required to render a set of tri's vs a tri-strip is the same.

The only times you will find strips outperforming lists is when you are not using indices to reference vertices (or for some reason you are using immediate mode openGL). At that point, tri-strips will require less vertices to be transformed on the GPU so will therefore be quicker. Otherwise, unless you are really short of ram, or are sending too much data across the bus to the GPU, they wont make any real difference.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!