So how can one update values in vertex buffer bound into device object using IASetVertexBuffers
method? Also will changing values in this buffer before call to Draw()
and Present()
? Also will the image be updated according to these new values in buffer?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- 如何让cmd.exe 执行 UNICODE 文本格式的批处理?
- 怎么把Windows开机按钮通过修改注册表指向我自己的程序
- Warning : HTML 1300 Navigation occured?
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
To update a vertex buffer by the CPU, you must first create a dynamic vertex buffer that allows the CPU to write to it. To do this, call
ID3D11Device::CreateBuffer
withUsage
set toD3D11_USAGE_DYNAMIC
andCPUAccessFlags
set toD3D11_CPU_ACCESS_WRITE
. Example:Now that you have a dynamic vertex buffer, you can update it using ID3D11DeviceContext::Map and ID3D11DeviceContext::Unmap. Example:
where sourceData is the new vertex data you want to put into the buffer.
This is one method for updating a vertex buffer where you are uploading a whole new set of vertex data and discarding previous contents. There are also other ways to update a vertex buffer. For example, you could leave the current contents and only modify certain values, or you could update only certain regions of the vertex buffer instead of the whole thing.
Each method will have its own usage and performance characteristics. It all depends on what your data is and how you intend on using it. This NVIDIA presentation gives some advice on the best way to update your buffers for different usages.
Yes, you will want to call this and
IASetVertexBuffers
beforeDraw()
andPresent()
to see the updated results for the current frame. You don't necessarily need to update the vertex buffer contents before callingIASetVertexBuffers
. Those can be in either order.