The VertexBuffer manages the lifetime of a bgfx::VertexBufferHandle.
More...
#include <vclib/bgfx/buffers/vertex_buffer.h>
|
| VertexBuffer ()=default |
| Empty constructor.
|
|
void | swap (VertexBuffer &other) |
| Swap the content of this object with another VertexBuffer object.
|
|
bool | isCompute () const |
| Check if the VertexBuffer is used for compute shaders.
|
|
void | setCompute (bool compute) |
| Set if the VertexBuffer is used for compute shaders.
|
|
void | create (const void *bufferData, uint vertNum, bgfx::Attrib::Enum attrib, uint attribNumPerVertex, PrimitiveType attribType, bool normalize=false, bgfx::ReleaseFn releaseFn=nullptr) |
| Creates the vertex buffer and sets the data for rendering.
|
|
void | createForCompute (const void *bufferData, const uint vertNum, bgfx::Attrib::Enum attrib, uint attribNumPerVertex, PrimitiveType attribType, bool normalize=false, bgfx::Access::Enum access=bgfx::Access::Read, bgfx::ReleaseFn releaseFn=nullptr) |
| Creates the vertex buffer and sets the data for compute shaders.
|
|
void | create (const bgfx::Memory *data, const bgfx::VertexLayout &layout, uint64_t flags=BGFX_BUFFER_NONE, bool compute=false) |
| Creates the vertex buffer and sets the data.
|
|
void | bind (uint stream, bgfx::Access::Enum access=bgfx::Access::Read) const |
| Bind the vertex buffer to the rendering pipeline.
|
|
The VertexBuffer manages the lifetime of a bgfx::VertexBufferHandle.
It provides an interface to set the vertex buffer data and bind it to the rendering pipeline. The vertex buffer can be used for rendering or for compute shaders.
- Note
- A VertexBuffer can be moved but not copied (a copy would require to create a new bgfx::VertexBufferHandle, that can be done only having access to the data). Any class that contains a VertexBuffer should implement the copy constructor and the copy assignment operator.
◆ VertexBuffer()
vcl::VertexBuffer::VertexBuffer |
( |
| ) |
|
|
default |
Empty constructor.
It creates an invalid VertexBuffer object.
◆ bind()
void vcl::VertexBuffer::bind |
( |
uint |
stream, |
|
|
bgfx::Access::Enum |
access = bgfx::Access::Read |
|
) |
| const |
|
inline |
Bind the vertex buffer to the rendering pipeline.
If the buffer is invalid, it is not bound.
- Parameters
-
[in] | stream | the stream (or stage, in case of compute) to which the vertex buffer is bound. |
[in] | access | the access type for the buffer (only for compute). |
◆ create() [1/2]
Creates the vertex buffer and sets the data.
If the buffer is already created (isValid() returns true
), it is destroyed and a new one is created.
- Parameters
-
[in] | data | the memory containing the data. |
[in] | layout | the vertex layout. |
[in] | flags | the flags for the buffer. |
[in] | compute | if true, the buffer is used for compute shaders. |
◆ create() [2/2]
Creates the vertex buffer and sets the data for rendering.
If the buffer is already created (isValid() returns true
), it is destroyed and a new one is created.
- Note
- The data must be available for two bgfx::frame calls, then it is safe to release the data. If you cannot guarantee this, you must provide a release function that will be called automatically when the data is no longer needed.
- 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. |
◆ createForCompute()
void vcl::VertexBuffer::createForCompute |
( |
const void * |
bufferData, |
|
|
const uint |
vertNum, |
|
|
bgfx::Attrib::Enum |
attrib, |
|
|
uint |
attribNumPerVertex, |
|
|
PrimitiveType |
attribType, |
|
|
bool |
normalize = false , |
|
|
bgfx::Access::Enum |
access = bgfx::Access::Read , |
|
|
bgfx::ReleaseFn |
releaseFn = nullptr |
|
) |
| |
|
inline |
Creates the vertex buffer and sets the data for compute shaders.
If the buffer is already created (isValid() returns true
), it is destroyed and a new one is created.
- Note
- The data must be available for two bgfx::frame calls, then it is safe to release the data. If you cannot guarantee this, you must provide a release function that will be called automatically when the data is no longer needed.
- 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] | access | the access type for the buffer. |
[in] | releaseFn | the release function to be called when the data is no longer needed. |
◆ isCompute()
bool vcl::VertexBuffer::isCompute |
( |
| ) |
const |
|
inline |
Check if the VertexBuffer is used for compute shaders.
- Returns
- true if the VertexBuffer is used for compute shaders, false otherwise.
◆ setCompute()
void vcl::VertexBuffer::setCompute |
( |
bool |
compute | ) |
|
|
inline |
Set if the VertexBuffer is used for compute shaders.
- Parameters
-
[in] | compute | if true, the VertexBuffer is used for compute shaders. |
◆ swap()
Swap the content of this object with another VertexBuffer object.
- Parameters
-
The documentation for this class was generated from the following file: