Sign in to follow this  

how to create ID3DXMesh from one vertex buffer and index buffer?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have create one object manually with vertex buffer and index buffer in DX9. In order to integrate the object to other meshes, it's neccerry to create one ID3DXMesh from the VB and IB. Will you show me how to realize that? thank you.

Share this post


Link to post
Share on other sites
Use D3DXCreateMesh() to create an instance of an ID3DXMesh with the correct amount of space allocated for IB's and VB's.

You can then use LockVertexBuffer() and LockIndexBuffer() to put your data in. I don't think it'll work to create your own VB/IB and simply swap the pointers out, but you could give it a shot.

The crucial, but oft overlooked detail is to update both the attribute table and attribute buffer. These are used by DrawSubset() to build the appropriate DrawIndexedPrimitive() parameters.

Use SetAttributeTable() and LockAttributeBuffer() to build these up. A simple one-element table and then assign every face to the same attribute should be sufficient if you want to be able to draw your entire mesh with one call, but obviously more complex partitioning is perfectly possible.



hth
Jack

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this