#include <gpumesh.h>
Public Member Functions | |
GPUMesh (RenderService &renderService, EMemoryUsage usage) | |
virtual | ~GPUMesh ()=default |
GPUMesh (const GPUMesh &other)=delete | |
GPUMesh & | operator= (const GPUMesh &other)=delete |
template<typename ELEMENTTYPE > | |
VertexBuffer< ELEMENTTYPE > & | addVertexBuffer (const std::string &id) |
const GPUBufferNumeric * | findVertexBuffer (const std::string &id) const |
GPUBufferNumeric & | getVertexBuffer (const std::string &id) |
IndexBuffer & | getOrCreateIndexBuffer (int index) |
const IndexBuffer & | getIndexBuffer (int index) const |
Defines the GPU data of a polygonal mesh. Every GPU mesh contains at least one, but often multiple, nap::VertexBuffer(s). A vertex buffer contains vertex data, for example: color, position, normal etc.
At least one nap::IndexBuffer is required, but multiple are supported. The index buffer controls how triangles are formed (from the vertex data) when rendered. A GPU mesh has more than 1 index buffer when it contains multiple shapes, one for each.
Together they outline the functionality and capabilities of a mesh.
A static mesh is updated (uploaded to) only once, a dynamic mesh can be updated more frequently but requires more resources and is 'generally' slower to draw, depending of the memory layout of the underlying hardware. It is not allowed to update a static mesh after the initial upload!
Note that static meshes are often placed in a different cache on the GPU, not accessible by the CPU, which allows for faster drawing times. 'DynamicWrite' meshes are uploaded into shared CPU / GPU memory and are therefore slower to draw.
GPUMesh | ( | RenderService & | renderService, |
EMemoryUsage | usage | ||
) |
renderService | render backend. |
usage | how the mesh data is used at runtime. |
|
virtualdefault |
VertexBuffer< ELEMENTTYPE > & addVertexBuffer | ( | const std::string & | id | ) |
Creates and adds a new vertex buffer to the mesh. The new buffer has yet to be initialized before it can be updated. This can be checked with isInitialized().
id | name of the vertex buffer to create and add. |
const GPUBufferNumeric* findVertexBuffer | ( | const std::string & | id | ) | const |
Finds a vertex buffer with the given name.
id | name of the vertex buffer |
const IndexBuffer& getIndexBuffer | ( | int | index | ) | const |
Returns an index buffer at the specified index, asserts if not present.
index | value of the index buffer to get. |
IndexBuffer& getOrCreateIndexBuffer | ( | int | index | ) |
Creates an index buffer if one does not exist, returns the existing buffer otherwise. If the buffer was created, it has yet to be initialized before it can be updated. This can be checked with isInitialized().
index | value of the index buffer to get or create. |
GPUBufferNumeric& getVertexBuffer | ( | const std::string & | id | ) |
Returns a vertex buffer with the given name, asserts if not present.
id | name of the vertex buffer to get. |