Advertisement Jump to content

DX11 Free-form line in 3D space

This topic is 558 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 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.




Share this post

Link to post
Share on other sites

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, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!