Skip to main content
gamedev.net
🔒 Locked

drawIndexedPrimitive problem!

Started by ylegoc Jun 19, 2002 at 7:17 AM 4 replies 300+ views
Original Post
ylegoc
ylegoc
hello, I encounter a problem with the drawIndexedPrimitive. I fill the vertexBuffer with 3 points like this: ...->lock(0, 0, (byte **)&vertex, 0); ... vertex[1].x = ... vertex[2].x = ... vertex[3].x = ... so much that the indexes I fill in the indexBuffer are 1, 2, 3. Then I call ...->setIndices(IB, 0) and it doesn''t work. This is not the right triangle which is displayed. Whereas, when I fill the indexBuffer with 0, 1, 2 and then call ...->setIndices(IB, 1) it works.
Krunk
Krunk
Arrays in C and C++ are 0 based - the first element in the array is accessed by array[0], the last by array[arraysize - 1].

[edited by - Krunk on June 19, 2002 8:29:29 AM]
ylegoc
ylegoc
krunk, you didn''t understand what I mean. I am trying to display a mesh with an indexbuffer, but it doesn''t work. So I tried to debug by displaying one triangle of which the vertices are referenced by any indexes. I remarked it worked when they were 0, 1, 2, but when I''m trying to display the triangle of which the indexes of its vertices are 1,2,3, it doesn''t work.
Krunk
Krunk
Hehe, yeah, sorry ''bout that... I just noticed the 1 in the SetIndices call. How are you calling DrawIndexedPrimitive in each case? Are you using the same parameters or not?
ylegoc
ylegoc
yes, the parameters are unchanged except the baseIndex in setIndices
Krunk
Krunk
Can you post the actual DrawIndexedPrimitive call you are using? Its just that if you used this:

dev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 3, 0, 1);

I don''t think the first way would work, because you go out of the vertex range specified in the call. You would need to use this instead:

dev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 4, 0, 1);

With the second method though, you are only accessing 3 vertices after BaseVertexIndex, so the either call would be OK (assuming the VB was bigger than 4 vertices).

Does the D3D debug runtime give you any complaints?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.