The DynamicVertexBuffer manages the lifetime of a bgfx::DynamicVertexBufferHandle.
More...
#include <vclib/bgfx/buffers/dynamic_vertex_buffer.h>
|
| DynamicVertexBuffer ()=default |
| Empty constructor.
|
|
void | swap (DynamicVertexBuffer &other) |
| Swap the content of this object with another DynamicVertexBuffer object.
|
|
bool | isCompute () const |
| Check if the VertexBuffer is used for compute shaders.
|
|
void | create (uint vertNum, bgfx::Attrib::Enum attrib, uint attribNumPerVertex, PrimitiveType attribType, bool normalize=false, bool allowResize=true) |
| Creates the dynamic vertex buffer data for rendering, with the layout given by the vertex attributes and without any data.
|
|
void | create (const void *bufferData, uint vertNum, bgfx::Attrib::Enum attrib, uint attribNumPerVertex, PrimitiveType attribType, bool normalize=false, bgfx::ReleaseFn releaseFn=nullptr, bool allowResize=true) |
| Creates the dynamic vertex buffer data for rendering, with the layout given by the vertex attributes and with the given data.
|
|
void | create (uint vertNum, const bgfx::VertexLayout &layout, uint64_t flags=BGFX_BUFFER_NONE, bool compute=false) |
| Creates the dynamic vertex buffer data for rendering, with the given layout and without any data.
|
|
void | update (const void *bufferData, uint vertNum, uint attribNumPerVertex, PrimitiveType attribType, uint startIndex=0, bgfx::ReleaseFn releaseFn=nullptr) |
| Updates the dynamic vertex buffer with the given data.
|
|
void | update (uint startIndex, const bgfx::Memory *data) |
|
void | bind (uint stream, bgfx::Access::Enum access=bgfx::Access::Read) const |
| Bind the dynamic vertex buffer to the rendering pipeline.
|
|
The DynamicVertexBuffer manages the lifetime of a bgfx::DynamicVertexBufferHandle.
It provides an interface to set the dynamic vertex buffer data and bind it to the rendering pipeline. The dynamic vertex buffer can be used for rendering or for compute shaders.
- Todo:
- provide here the differences between a vertex buffer and a dynamic vertex buffer.
- Note
- A DynamicVertexBuffer can be moved but not copied (a copy would require to create a new bgfx::DynamicVertexBufferHandle, that can be done only having access to the data). Any class that contains a DynamicVertexBuffer should implement the copy constructor and the copy assignment operator.
◆ DynamicVertexBuffer()
vcl::DynamicVertexBuffer::DynamicVertexBuffer |
( |
| ) |
|
|
default |
◆ bind()
void vcl::DynamicVertexBuffer::bind |
( |
uint |
stream, |
|
|
bgfx::Access::Enum |
access = bgfx::Access::Read |
|
) |
| const |
|
inline |
Bind the dynamic vertex buffer to the rendering pipeline.
- Parameters
-
[in] | stream | the stream (or stage, in case of compute) to which the dynamic vertex buffer is bound. |
[in] | access | the access type for the buffer (only for compute). |
◆ create() [1/3]
Creates the dynamic vertex buffer data for rendering, with the layout given by the vertex attributes and with the given data.
If the buffer is already created (isValid() returns true
), it is destroyed and a new one is created.
- Parameters
-
[in] | bufferData | the data to be copied in the vertex buffer. |
[in] | vertNum | the number of vertices in the buffer. |
[in] | attrib | the attribute to which the data of the buffer refers. |
[in] | attribNumPerVertex | the number of attributes per vertex. |
[in] | attribType | the type of the attributes. |
[in] | normalize | if true, the data is normalized. |
[in] | releaseFn | the release function to be called when the data is no longer needed. |
[in] | allowResize | if true, the buffer can be resized. |
◆ create() [2/3]
Creates the dynamic vertex buffer data for rendering, with the layout given by the vertex attributes and without any data.
If the buffer is already created (isValid() returns true
), it is destroyed and a new one is created.
- Parameters
-
[in] | vertNum | the number of vertices in the buffer. |
[in] | attrib | the attribute to which the data of the buffer refers. |
[in] | attribNumPerVertex | the number of attributes per vertex. |
[in] | attribType | the type of the attributes. |
[in] | normalize | if true, the data is normalized. |
[in] | allowResize | if true, the buffer can be resized. |
◆ create() [3/3]
Creates the dynamic vertex buffer data for rendering, with the given layout and without any data.
- Parameters
-
[in] | vertNum | the number of vertices in the buffer. |
[in] | layout | the vertex layout. |
[in] | flags | the flags for the buffer. |
[in] | compute | if true, the buffer is used for compute shaders. |
◆ isCompute()
bool vcl::DynamicVertexBuffer::isCompute |
( |
| ) |
const |
|
inline |
Check if the VertexBuffer is used for compute shaders.
- Returns
- true if the VertexBuffer is used for compute shaders, false otherwise.
◆ swap()
◆ update()
Updates the dynamic vertex buffer with the given data.
If the buffer is not valid, the data is not updated. If the buffer was created with the allowResize flag set to true, the buffer can be resized to fit the new data. Otherwise, only the data that fits the buffer is updated.
- Parameters
-
[in] | bufferData | the data to be copied in the vertex buffer. |
[in] | vertNum | the number of vertices in the buffer. |
[in] | attribNumPerVertex | the number of attributes per vertex. |
[in] | attribType | the type of the attributes. |
[in] | startIndex | the index of the first vertex to be updated. |
[in] | releaseFn | the release function to be called when the data is no longer needed. |
The documentation for this class was generated from the following file: