Quads vs. Triangles (And various simple questions)

Started by
14 comments, last by Rellik 20 years, 5 months ago
Hi. Which is more efficient, rendering two triangles, or a single quad? And besides that, how much more efficient is using a Triangle Strip for a single quad? Just a simple question; I might as well lump in some other stuff. In a vertex array, if you want to bind a different texture while drawing elements, is there any way to signify that inside the array? There are texel arrays and vertex arrays, but no currently-binded-texture arrays, correct? Also, this is more of a C++ question, but for exactly how long does memory allocated off the heap but never returned stay on the system? Until a restart? Is there some kind of a garbage collecting system like in Java? Is there any way to manually deallocate the memory, with a helper program or something? Is it possible to use vector graphics as textures? Unlike raster graphics, vector graphics will stay smooth and detailed even up close. Although there is some charm in using GL_NEAREST magnification, it would be better just to have such a high level of detail as is provided with vector graphics. Thanks; I just had a lot of questions, I guess. I still have more, but I feel I''ve already asked enough for now. Thanks again =D.
End of Post
Advertisement
I just recently tested triangles and triangle strips vs good ol quads. Quads was like 30/40% faster then one of em, and like 10% faster then the other (i forgot exactly which hehe

Quads all the way!!
quote:Original post by TinkleBear
I just recently tested triangles and triangle strips vs good ol quads. Quads was like 30/40% faster then one of em, and like 10% faster then the other (i forgot exactly which hehe

Quads all the way!!


When used properly, triangle strips are fastest, quads second fastest, and triangles slowest. The reason is, with triangle strips, to draw N triangles, it takes N+2 vertices to draw them. To draw N triangles as triangles, it takes N*3 vertices, and to draw N triangles as quads it takes N*2 vertices (must be an even number of triangles though and be made of quads). So, lets plug a number in for this to test with... first an extremly simple model, like a box.. 6 sides, 2 triangles per side = 12 triangles. To render with triangle strings, that''s a total of 12+2 vertices passed to the graphics board, so 14. Rendered with quads, it''s 12*2, so 24 vertices passed, and with plain triangles, you''d have to pass 12*3, so 36 vertices. As you can see, the one that is moving the least memory around is the triangle strips, and since all 3 of these are actually rendered as triangles using the exact same rasterizer, the one that uses the least bandwidth will be fastest, and that happens to be triangle strips.
Pardon the n00b question, but what about quad strips ?
hm, i tried hard to find a way to render a box as a single strip and as soon as those three require different numbers of drawing calls it wont help to look at bandwith alone.

but if this about which is better to draw single billboards then: it doesnt matter, rendering only two triangles per call is absolutely efficient no matter what primitive you use and so this should be pretty much the last question on your mind ,-)
f@dzhttp://festini.device-zero.de
Ready: How does one render a triangle strip incorrectly?
quote:Original post by Rellik
Also, this is more of a C++ question, but for exactly how long does memory allocated off the heap but never returned stay on the system? Until a restart? Is there some kind of a garbage collecting system like in Java?

Any half decent OS should be keeping track of memory use of your process (ie. your app) and be able to reclaim it when your program quits.

WinNT and derivitives will do this, so will all *nix systems I''d expect. The most obvious contradiction to this is Win9x which will only reclaim it on a system reboot.

Video memory is slightly different. In theory it should be the same, but again driver bugs may mean its only reclaimed on a reboot. In short, clean up your own mess.
quote:Original post by TinkleBear
Ready: How does one render a triangle strip incorrectly?


Very carefully...

No, seriously, it''s pretty hard to render them incorrectly, but my point was TinkleBear was either rendering the incorrectly, or something was not right. If you render as triangle strips, it should always be faster unless you''re rendering 2 or less triangles, as there are A.) less function calls if using the regular glVertexf calls and/or B.) less memory being transfered across from memory -> through agp bus -> video card. There is no reason quads would be faster than triangle strips unless you used vertex arrays for the quads, and regular glVertex calls for the triangle strips (or possibly had your indices messed up?).
Maybe me card just like quads? All knowing beings frustate me >.<
How is it that render quads it N X 2. It should be N X 4.

As far as i know Triangles strips are the fastest followed by Triangles with Quads being the slowest. You wont see any difference until you render a few thousand of them.

This topic is closed to new replies.

Advertisement