Skip to main content
GameDev.net gamedev.net
🔒 Locked

DrawIndexedPrinitive

Started by wooord Apr 18, 2001 at 6:16 PM 5 replies 450+ views
Original Post
wooord
wooord
In VC++ 6, I have a class to represent each sprite(game object). a method in each class takes the D3DX8 device as a paramater. The first few operations on the device(SetTexture, SetStreamSource, etc) are successful, but when it comes to DrawIndexedPrimitive I get a VC++ Access Violation error. Any ideas why?? Thanks.
Grugnorr
Grugnorr
Show us that method´s code.
You will probably trying to acces to some data outside the vertex buffer(it is like an array). Check your
UINT MinIndex,
UINT NumVertices,
UINT StartIndex,
UINT PrimitiveCount
params.



.-Question:Is there an typpo,bug or how you want to call it in the C++ DX8.0 SDK, in the DrawPrimitive page, at the very bottom: it does:

d3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 5 );
to draw a 4 triangles mesh. They must have looked at the upper mesh...




What the hells!
What the hells!
Friday13
Friday13
>DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0,
>sizeof(indices) / sizeof(indices[0]), 0, ...

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!!!

The number of vertices in VB may not always equal to
the number of indices. Suppose you have just one vertex
and, say, 28 indices referring to it. You should pass
the actual number of vertices, NOT INDICES!


zechis
zechis
Also, you correctly set your stream source (the vertices) but you forgot to set your index source. You need to call:

pD3dDevice->SetIndices( [IDirect3DIndexBuffer8* here], 0 );

...before you call DrawIndexedPrimitive(). This will also cause an access violation because DX will try to access a non-existant index buffer.
wooord
wooord
I fixed the problem..it turned out to be a c++ problem.

I am a java programmer, so I''m learning DX and c++ at the same time.

In my class def, I declared direct references to my sprites and it caused the sprite objects to go out of scope too early. I changed the declarations to be pointers and it fixed it. Why is this?

Topic Locked

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

Sign in to reply to this topic.