Jump to content
  • Advertisement
Sign in to follow this  
gomidas

C# SharpDX how to use dynamic vertex buffers

This topic is 467 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 am using a static vertex buffer. I need to get immediate update of vertex positions how can I achieve that instead re-creating a buffer everytime ? After getting dynamic buffer how will I update positinos ?

 

Thanks if anyone answer.

Share this post


Link to post
Share on other sites
Advertisement

I'm not familiar with SharpDX but it's likely that you would need to lock the vertex buffer and then copy the new vertex positions into the vertex buffer. After that you need to unlock the vertex buffer so it can be used to draw again.

Looking at the SharpDX source code this is indeed what you need to do: https://github.com/sharpdx/SharpDX/blob/master/Source/SharpDX.Direct3D9/VertexBuffer.cs

Share this post


Link to post
Share on other sites

I'm not familiar with SharpDX but it's likely that you would need to lock the vertex buffer and then copy the new vertex positions into the vertex buffer. After that you need to unlock the vertex buffer so it can be used to draw again.

Looking at the SharpDX source code this is indeed what you need to do: https://github.com/sharpdx/SharpDX/blob/master/Source/SharpDX.Direct3D9/VertexBuffer.cs

Alright, that would be perfect if there was an example usage about how will I put them inside. Buf for retriving existing cooords I do not have use that I can get correct positions over matrix and pass transformed coords to VertexData instead of it huh ? I think access is for animations (?)

Share this post


Link to post
Share on other sites

I googled "sharpdx tutorial vertex buffer" and this was one of the links:

https://gamedev.stackexchange.com/questions/49727/proper-use-of-dynamic-vertex-buffers-for-rapid-update

This has a snippet of code using Map/Unmap to lock/unlock the vertex buffer.

 

Hmm I just noticed that the repository I linked to was for Direct3D9, which is a bit old. I'm guessing you're using the Direct3D11 version of SharpDX? That code snippet is for 10 but I think the APIs have stayed mostly the same between 10 and 11. 

Share this post


Link to post
Share on other sites

I googled "sharpdx tutorial vertex buffer" and this was one of the links:

https://gamedev.stackexchange.com/questions/49727/proper-use-of-dynamic-vertex-buffers-for-rapid-update

This has a snippet of code using Map/Unmap to lock/unlock the vertex buffer.

 

Hmm I just noticed that the repository I linked to was for Direct3D9, which is a bit old. I'm guessing you're using the Direct3D11 version of SharpDX? That code snippet is for 10 but I think the APIs have stayed mostly the same between 10 and 11. 

Hmm, I am going to check that thank you very much.

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!