IndexBuffer size reflect primitive count?

Started by
9 comments, last by skillfreak 18 years, 10 months ago
I am creating an IndexBuffer at a necessary size to hold every triangle in my terrain. Although only a few triangles will be drawn do to culling. I can verify that the primitive count is only 975, the vertices are correct, but the index buffer is causing an error at vertice 52685 which means the DrawIndexedPrimitive is trying to draw primitives for the entire size of the index buffer....
Advertisement
so would our answer be, your indexing wrong?
Remember, there are three vertices per primitive (triangle). That means with 975 primitives, you should have 2925 indices. Can you post your DIP() code? Perhaps you have some parameters wrong.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
m_terrainIBuffer.SetBufferIndices();
m_terrainVBuffer.Stream();
::Graphics()->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, m_iNumVertices, 0, m_iNumVertices/3);


Is that the code you wanted to see?
I can't really post my whole quadtree, heightmap and terrain class' and expect you to debug it.

Fortunetly my problem has changed, I no longer recieve the error. I wasn't setting the buffer I use to copy into the index buffer to zero. I cannot be to sure why that fixed it...


See my only Q is, if I INIT an INDEX BUFFER to a size of 65534 and I use that index buffer to render only 975 primitives will DX be (i'm sure it is) smart enough to only look through 975*3 indices or will it just try and go for the whole batch for some dumb reason...
Yea, you are calculating the last parameter incorrectly. It should be the number of faces/triangles, not numVertices / 3. numVertices / 3 is not necessarily the number of faces/triangles, since the primitive types are arranged differently.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
Well now I feel very stupid.
I am quite new to DX9, so I guess its okay.

What should I be setting the last parameter as then?
Quote:Original post by Halsafar
Well now I feel very stupid.
I am quite new to DX9, so I guess its okay.

What should I be setting the last parameter as then?

The forum FAQ has a very good explanation of how DIP works here, as well as links for more.

Thanks for the article it was worth a refresh/comparison to Dx7 which I've used for 2 years.


Now, Primitive count with triangle_list can be easily expressed as:
iNumIndices / 3???
Quote:Now, Primitive count with triangle_list can be easily expressed as:
iNumIndices / 3???

Yep. When dealing with indices/faces/primitives, you almost always use index buffer values. When you deal with vertices, it's almost definitely going to be relative to the vertex buffer.
Well now that all these questions have been answered I cannot seem to find my problem.

I have a big vertex buffer and a big index buffer.
I have made sure that my vertices and indices match up properly for at least the first 32 triangles which are the only 32 I am trying to render.

They are being rendered with a basic world matrix, they should be appearing at 0,0,0.

I see obsolutely nothing, I've tried everything.
My frame-rate is jumping as if I was rendering the triangles but they are clearly not there. It has been rather frusterating.

If I turn back on my culling and attempt to render the batch's the quad tree provides I can watch my frame rate jump around a bit as I approach where the center of the world should be the place with the highest number of vertices/indices... My frame-time clearly shows rendering is taking place but nothing is showing.

I have tried with D3DCULL_NONE.
I have lighting off, I have 0xFFFFFFFF set for ambient.

I'm out of idea's....

This topic is closed to new replies.

Advertisement