should i use quads with drawprimitive for tiles?

Started by
11 comments, last by Ilankt 20 years, 8 months ago
because sprites dosent give me good rotation... and if i will use tiles, and lets say i will have let''s say 500 calls for drawprimitive, the program wont get slow?
How appropriate, you fight like a cow!
Advertisement
It depends on how you make the drawprimitive call. If you call drawprimitive 500 times every frame it will be too slow. If you create a vertex buffer and fill it with all your tile vertices and call drawprimitive once every frame then it will be extremely fast.
hmm...
I dont know exactly how to do it, but I will check this out...
thanks
How appropriate, you fight like a cow!
it also depends on everything else, how complex the rest of your game is and stuff, and if your doing level-of-detail management - which you probably arent in this case.

but yeah, placing all vertices into a vertex buffer, even better using triangle strips, can all help in the performance area.
Hmm...this brings up a question i never thought about.
When using triangle fans with DrawPrimitiveUP(), can i draw multiple fan or am I limited to one fan per DrawPrimitiveUP?
Don''t use DrawPrimitiveUP(). It''s much slower than DrawPrimitive()
I''ve done this myself so I have an idea about it. Strips won''t help you that much if you want to draw 500 quads in one DP because of the different texture coordinates for each tile. You''re best bet is to use triangle lists. Use an index buffer so you save on 2 verts. You won''t have to worry about a performance hit if all your tiles are in one texture (I have all my 16x16 tiles in one 512x512 texture). Also if all you''re tiles don''t fit into just one try to group them someway (I matched tiles into a forest texture, a town texture, a snow texture, etc).
First of all, if you''re using DrawPrimativeUP, then performance probably isn''t your main concern. Most people only use UP for quick tests/hacks but not for all rendering. Now, 500 calls to DrawPrimative per frame doesn''t sound too bad if that''s for rendering your whole scene. Modern CPU''s/GPU''s are fast enough to handle this kind of driver abuse. If it''s all static, you''re better off using a vertex buffer though.
~25000 DIP calls per second = 100% CPU USAGE on a 1 ghz machine. Assuming 100 frames per second (which is modest if you are just doing 2d with 3d), that is 250 calls per frame. Add on collision detection, ai, etc... You should make it one call if at all possible.
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
OK, i see this alot, so I gotta ask.
Someone mentioned that if it''s static then the best bet would be the use of vertex buffers.

Is this opposed to the use of index buffers?

What if the scene if not static, meaning there is LOD management going on, so at one point there might be more vertices in a forest scene, and in another moment, there might be less vertices in the same scene. Since this is anything but static, would vertex buffers be a bad thing in particular or just an unconventional way?

I plan on using vertex buffers for my dynamic scene. then if need be, index buffers.

This topic is closed to new replies.

Advertisement