Archived

This topic is now archived and is closed to further replies.

nhatkthanh

problem with DrawIndexedPrimitive.

Recommended Posts

I have a dynamic buffer that I use to stuff vertices into (for billboarding) each frame I copy a certain number of quads into the buffer. The buffer can hold about 10 times as much as i can stuff in. The problem is that suppose the buffer is now half full and i''m going to fill it up with some more vertex data similar situation for the index buffer ......it''s getting hard for me to explain, so i''m going to try to draw some ascii picture. Dynamic VB: suppose it can hold 10 vertices |---------------------------------| Dynamic IB: suppose it can hold 20 indices (for trianglelist) |------------------------------------------------------| now suppose each frame i want to copy a triangle to the VB and 3 indices into the IB, as I do this I obtain the offset from the base of these 2 buffers. for example my VB has been fill with 2 vertices and now I want to copy another 3 vertices into it which I then obtain the offset as 2. this is the code i setup to render

VertexType *tempvb = dvb->Lock( nVert, startvb );
.... copy vertices here
dvb->Unlock();

Indextype *tempib = dib->Lock( nTri*3, startib);
.....
dib->Unlock();


ge->GetDevice()->SetStreamSource(0, dvb->GetInterface(), sizeof(VertexType));
ge->GetDevice()->SetIndices(dib->GetInterface(),startvb);
ge->GetDevice()->SetVertexShader(FVF);
ge->SetTransformMatrix(m);
	
ge->GetDevice()->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,startvb,maxVert,startib,maxTri);

 
i''m pretty sure the problem is setting the minindex, base index etc... I not sure what the documentation said, as English is not my main language. Hope someone can help me with this. thanks.

Share this post


Link to post
Share on other sites
This paper (pdf) from GDC has a really nice diagram of what all the parameters mean precisely, on page 18.


Most of the greatest evils that man has inflicted upon man have come through people feeling quite certain about something which, in fact, was false.

-Bertrand Russell, Unpopular Essays, "Ideas That Have Harmed Mankind"

Share this post


Link to post
Share on other sites