Archived

This topic is now archived and is closed to further replies.

Rellik

Quads vs. Triangles (And various simple questions)

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 ,-)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
How can quads be 40% faster than tris?!!?! It is impossible. What card do you have?!



Member of the Shove Pouya Off A Cliff club, SPOAC . (If you wish to join, add this line to your signature.)
Member of "Un-Ban nes8bit" association, UNA (to join put this in your sig)

"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

Share this post


Link to post
Share on other sites
It is impossible. Try drawing 1000 quads vs. 2000 triangle strips.



Member of the Shove Pouya Off A Cliff club, SPOAC . (If you wish to join, add this line to your signature.)
Member of "Un-Ban nes8bit" association, UNA (to join put this in your sig)

"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

Share this post


Link to post
Share on other sites
quote:
Original post by TinkleBear
Ati radeon 9000 agp(64mb ddr)

I just drew a 480x480 area using 32x32 tiles,no display list or nofin''. got around 900 fps with one of them ,triangles i guess, and my quad code gets 1300+ all times.

Well, of course, if you use immediate mode. Try drawing a few thousand indexed triangle lists or strips from a compiled vertex array and you''ll see the difference.

- JQ

Share this post


Link to post
Share on other sites
quote:
Original post by GamerSg
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.


No, it should be N * 2 like I said... 4 vertices in a quad, but 2 triangles... so 2 triangles per 4 vertices = 2 vert''s per tri average... so Number of Triangles (N) * 2.

Quads are faster, as you don''t have to make as many vertex calls (if using glVertex calls), and there is less data that must travel around, since each 2 triangles takes 4 vertices, as opposed to 2 triangles taking 6 vertices with triangles. Quads are simply drawn as 2 triangles, so there is no reason they should be slower than triangles, since there is less over-head (function call and/or memory bandwidth).

Share this post


Link to post
Share on other sites
quote:
Original post by CPPMaster Poppet
It is impossible. Try drawing 1000 quads vs. 2000 triangle strips.



Member of the Shove Pouya Off A Cliff club, SPOAC . (If you wish to join, add this line to your signature.)
Member of "Un-Ban nes8bit" association, UNA (to join put this in your sig)

"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"



Yes, triangle STRIPS are faster than quads, like I said. He''s talking about regular trianbles, which are the slower.

Share this post


Link to post
Share on other sites