# Vertex Buffer Issue

This topic is 4852 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have a vertex buffer filled, index buffer filled, and when I render the model, it shows up fine... I'm manual parsing this file by the way. edit: Since there are two materials, I split the indicies into two groups, there are 600 faces. when I render like this: m_RenderingDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,m_VertexCount,0,600); //everything shows up fine. When I render like this with 2 calls: m_RenderingDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,m_VertexCount,0,300); m_RenderingDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,m_VertexCount,301,600); I see some of the model and a bunch of missing triangles. Any idea why? By the way, those calls are in loops, I'm resetting the vertex buffer and index buffer etc. But this should render the whole model, I'm just seperating the faces into parts right?? Why is this not working? Thanks a lot Jeff [Edited by - webjeff on August 7, 2005 2:25:35 PM]

##### Share on other sites
Hi there webjeff,
How are you doing?

[The problem]
When you split up your render calls you are missing some triangles.
[source lang = c++]//everything shows up fine.m_RenderingDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,m_VertexCount,0,600);//This is brokenm_RenderingDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,m_VertexCount,0,300);m_RenderingDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,m_VertexCount,301,600);

[The solution]
Let's look at the call you are invoking.
HRESULT DrawIndexedPrimitive(
D3DPRIMITIVETYPE Type,
INT BaseVertexIndex,
UINT MinIndex,
UINT NumVertices,
UINT StartIndex,
UINT PrimitiveCount
);

1) You are saying there are "there are 600 indicies.".
This does not mean it has 600 primitives.

Example:
a quad has 4 indices but only 2 primitives.

2) Also the 2nd last parameter is the start index. You are specifying that the index is 301, which might be wrong..

3) The last parameter takes the number of primitives to be drawn, not the number of indices :)

[Conclusion]

I hope this helps a bit.
Keep cool

##### Share on other sites
No you are absolutely correct.

I was typing too fast :). There are 600 faces, not indicies. so I am rendering have the faces. each face contains 3 indicies. Sorry for the confusion.

I will edit the post to make clearer. But I am doing 600 FACES not indicies. Thanks for the mixup. Any other ideas on why that might be wrong?

Thanks
Jeff.

##### Share on other sites
I found the problem... Just incase you run into the same thing, read the docs closer.

These lines are wrong:
m_RenderingDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,m_VertexCount,0,300);
m_RenderingDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,m_VertexCount,301,600);

should be:
m_RenderingDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,m_VertexCount,0,300);
m_RenderingDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,m_VertexCount,301*3,300);

Notice the *3, its the index start, not the primative start, I was thinking the last two parameters were the same. also, the last param should be the count, not the total.

Those 2 things fixed it.

##### Share on other sites
Quote:
 But I am doing 600 FACES not indicies.

Exactly. You are drawing 300 faces, not indices, meaning 300 faces * 3 indices per face = 900 indices.

Also, in you DIP call, the last parameter is not an "end index" value. It's the number of primitives to draw. So, your calls should be..

m_RenderingDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,m_VertexCount,0,300);m_RenderingDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,m_VertexCount,900,300);

First batch starts at index 0 and draws 300 faces. Each face is 3 indices, so indices 0-899 are used. Then, the second batch begins at index 900 (first undrawn index) and draws the other 300 faces.

Dammit, you figured it out ;)

1. 1
Rutin
47
2. 2
3. 3
4. 4
5. 5

• 10
• 27
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633405
• Total Posts
3011682
• ### Who's Online (See full list)

There are no registered users currently online

×