Jump to content
  • Advertisement
Sign in to follow this  
sunrisefe

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

This topic is 3330 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!