Jump to content
  • Advertisement
YixunLiu

DX11 Free-form line in 3D space

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

Hi,

I want to use a 3D mouse to draw free-form line in 3D space using DirectX11.

I have a question about how to create vertex buffer. Please see comments in the following code.

struct SimpleVertexCombined
{
    XMFLOAT3 Pos;  
    XMFLOAT3 Col;  
};
D3D11_BUFFER_DESC bufferDesc;
bufferDesc.Usage            = D3D11_USAGE_DYNAMIC;
bufferDesc.ByteWidth        = ???;//the size will change dynamically, how to fill this part?
bufferDesc.BindFlags        = D3D11_BIND_VERTEX_BUFFER;
bufferDesc.CPUAccessFlags   = 1;
bufferDesc.MiscFlags        = 0;

 

After I create a dynamic vertex buffer, I use Map and UnMap to update the buffer.

How to incrementally update the buffer?

Any comments about how to do free-form line drawing in 3D space are really appreciated.

 

Many thanks.

 

YL

 

Share this post


Link to post
Share on other sites
Advertisement

You can't change the size of the buffer once you've created it, so you need to make sure the buffer is large enough to hold all the vertices you will need. One thing you could try is once a buffer has reached its limit, destroy it and create another buffer maybe twice as big. once that one has reached its limit do the same to that one.

Edited by iedoc

Share this post


Link to post
Share on other sites

  • 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!