   DrawPrimitive or DrawIndexedPrimitive
  Hey all,I know that there has been many post's on using DrawPrimitive or DrawIndexedPrimitive but I'm still confused after a search here on gamedev. My question is: What is best, "CODE1" or "CODE2" ??-- CODE1: --poly[4]={ {..},{..},{..},{..} };// .. create vertex buffer here from poly[]mDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);-- CODE2: --mDevice->SetIndices(myIndexBuffer, 0);mDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, ... );I both cases I'm working with 4 vertices. My problem is that I'm rendering a world with many different textures, so I'll eventually have many calls to DrawIndexedPrimitive or DrawPrimitive after the setTexture call. So what should I go for, DrawPrimitive or DrawIndexedPrimitive ??Please help me, I'm a DX newbi ..[edited by - Mille on February 10, 2004 4:35:15 PM]
  Whats going to really kill your performance is that it looks like you are issuing many very small 2-triangle batches.  I''d use indexed triangle lists, and try to batch as many quads together into a single DrawIndexedPrimitive call as possible.  Also sort by texture to help batching.  You might want to try ID3DXSprite, since it can do the batching/sorting for you.xyzzy ;quote:Original post by xyzzy00  Whats going to really kill your performance is that it looks like you are issuing many very small 2-triangle batches.  I''d use indexed triangle lists, and try to batch as many quads together into a single DrawIndexedPrimitive call as possible.  Also sort by texture to help batching.  You might want to try ID3DXSprite, since it can do the batching/sorting for you.xyzzy   Allright, thanks, I like the sort by texture idear - but it sure needs some work before I can get DrawIndexPritive to work ... but that''s not your problem ;  I don''t think there is a noticable performance difference when you use either of those pieces of code, since it is only done with 2 triangles.  Sometimes you do need 2 triangles only, such as if you are rendering a bunch of different textured quads that will only be on the screen in ONE spot.  In those cases, I find it best to use DrawPrimitive because it saves the extra memory of an index list.  However, go with Indices if the object being drawn:1) will be used more than once.2) the object''s texture will be used more than once.3) will contain more than 4 shared vertices than cannot be drawn in a single strip.Always try to:1) Keep SetTextures to a minimum.2) Keep DrawPrimitive or DrawIndexedPrimitive calls to a minimum.3) Keep memory locking of Vertex Buffers to a minimum.Chris ;Ok Chris, thanks for your imput, I fianlly understand how to go about rendering my stuff ..