NeTBaPb

hi.

one of the DrawIndexedPrimitives method parameters is NumVertices that specify number of vertices during the call as all you know. but i faced a problem that this parameter reads vertices that are one after anothe in the vertexbuffer. let me explain my problem on a picture:

for example i have such vb:

1 5 9 13

2 6 10 14

3 7 11 15

4 8 12 16

and i need to draw triangles that uses 1, 2, 5 and 6 vertices i.e. 4 vertcices at all. but as you may guess if i will pass 4 as numvertices function will only read 1, 2, 3, 4 verts.

my question is: what is better

1. to pass whole (or for example bigger part of vb) to function

2. fill my vb in block-style, i.e.:

1 2

3 4

5 6

7 8...

where 3 and 4 are equal to 5 and 6 accordingly and so on.

p.s. it's interesing what stands behind DrawIndexedPrimitives (and any other draw call), how much vertices are really send to videocard etc..




Re: XNA Framework issue about DrawIndexedPrimitives

Kyle_W

The fewer draw calls per frame you have, the better your performance will be. How you organize your index buffer depends on what kind of triangle primitive you want to draw. There are three types: triangle lists, triangle strips, and triangle fans. In the context of XNA, these are described here:

http://msdn2.microsoft.com/en-us/library/bb196414.aspx

There is a better description of the primitives themselves in the DirectX reference:

http://msdn2.microsoft.com/en-us/library/ms924577.aspx

Basically, you should use triangle strips or triangle fans where you can because you can draw groups of connected triangles with fewer elements in your index buffer. However you can use a triangle list to draw disjointed groups of triangles. If you still don't understand something, post a follow up question and I or someone else can try and clarify for you.





Re: XNA Framework issue about DrawIndexedPrimitives

NeTBaPb

thx for the reply of cource, but i know what is fans, strips and that strips are better then lists :)

i just want to know if i will pass length of my vb (i.e. whole vb) as numVertices to draw call will all vertices be send video card. if yes then probably i'll reconstruct my vb in more suitable way.

p.s. stilll confused why this parameter is involved in function.. coz if i draw with indexes it may be assumed that i will use few vertices from all over the vertex buffer, not only from one part of it...






Re: XNA Framework issue about DrawIndexedPrimitives

Kyle_W

It appears that you have to include the entire range of vertices that you intend to use. The index buffer cannot reference vertices outside of the range you specify.

The following paragraph is from the help on DrawIndexedPrimitives:

The minVertexIndex and numVertices parameters specify the range of vertex indices used for each call to DrawIndexedPrimitives. These vertex indices are used to optimize vertex processing of indexed primitives by processing a sequential range of vertices prior to indexing into them. Indices used during this call cannot reference any vertices outside this range.

Reference:

http://msdn2.microsoft.com/en-us/microsoft.xna.framework.graphics.graphicsdevice.drawindexedprimitives.aspx