libdonut  2.3.2
Application framework for cross-platform game development in C++20
Public Member Functions | Static Public Attributes | List of all members
donut::graphics::Mesh< Vertex, Index, Instance > Class Template Reference

Generic abstraction of a GPU vertex array object and its associated buffers. More...

#include <donut/graphics/Mesh.hpp>

Public Member Functions

 Mesh (MeshBufferUsage verticesUsage, std::span< const Vertex > vertices) requires(!IS_INDEXED &&!IS_INSTANCED)
 Constructor for meshes that only have a vertex buffer. More...
 
 Mesh (MeshBufferUsage verticesUsage, MeshBufferUsage indicesUsage, std::span< const Vertex > vertices, std::span< const Index > indices) requires(IS_INDEXED &&!IS_INSTANCED)
 Constructor for meshes that have a vertex buffer and an index buffer. More...
 
 Mesh (MeshBufferUsage verticesUsage, MeshBufferUsage instancesUsage, std::span< const Vertex > vertices, std::span< const Instance > instances) requires(!IS_INDEXED &&IS_INSTANCED)
 Constructor for meshes that have a vertex buffer and an instance buffer. More...
 
 Mesh (MeshBufferUsage verticesUsage, MeshBufferUsage indicesUsage, MeshBufferUsage instancesUsage, std::span< const Vertex > vertices, std::span< const Index > indices, std::span< const Instance > instances) requires(IS_INDEXED &&IS_INSTANCED)
 Constructor for meshes that have a vertex buffer, an index buffer and an instance buffer. More...
 
void setVertices (MeshBufferUsage verticesUsage, std::span< const Vertex > vertices) noexcept requires(!IS_INDEXED)
 Set the contents of the vertex buffer. More...
 
void setVertices (MeshBufferUsage verticesUsage, MeshBufferUsage indicesUsage, std::span< const Vertex > vertices, std::span< const Index > indices) noexcept requires(IS_INDEXED)
 Set the contents of the vertex and index buffers. More...
 
Handle getVertexBuffer () const noexcept
 Get an opaque handle to the GPU representation of the vertex buffer. More...
 
Handle getIndexBuffer () const noexcept requires(IS_INDEXED)
 Get an opaque handle to the GPU representation of the index buffer. More...
 
Handle getInstanceBuffer () const noexcept requires(IS_INSTANCED)
 Get an opaque handle to the GPU representation of the instance buffer. More...
 
Handle get () const noexcept
 Get an opaque handle to the GPU representation of the vertex array. More...
 

Static Public Attributes

static constexpr bool IS_INDEXED = !std::is_same_v<Index, NoIndex>
 Tells if the mesh has an index buffer or not. More...
 
static constexpr bool IS_INSTANCED = !std::is_same_v<Instance, NoInstance>
 Tells if the mesh has an instance buffer or not. More...
 

Detailed Description

template<typename Vertex, typename Index = NoIndex, typename Instance = NoInstance>
class donut::graphics::Mesh< Vertex, Index, Instance >

Generic abstraction of a GPU vertex array object and its associated buffers.

Template Parameters
Vertextype of vertices stored in the vertex buffer. Must meet the requirements of the donut::graphics::mesh_vertex concept.
Indextype of indices stored in the index buffer, or NoIndex for no index buffer. Must meet the requirements of the donut::graphics::mesh_index concept.
Instancetype of instances stored in the instance buffer, or NoInstance for no instance buffer. Must meet the requirements of the donut::graphics::mesh_instance concept.

Constructor & Destructor Documentation

◆ Mesh() [1/4]

template<typename Vertex , typename Index = NoIndex, typename Instance = NoInstance>
donut::graphics::Mesh< Vertex, Index, Instance >::Mesh ( MeshBufferUsage  verticesUsage,
std::span< const Vertex >  vertices 
) &&
inline

Constructor for meshes that only have a vertex buffer.

Parameters
verticesUsageintended access pattern of the vertex buffer, see MeshBufferUsage.
verticesinitial data to copy into the vertex buffer.

◆ Mesh() [2/4]

template<typename Vertex , typename Index = NoIndex, typename Instance = NoInstance>
donut::graphics::Mesh< Vertex, Index, Instance >::Mesh ( MeshBufferUsage  verticesUsage,
MeshBufferUsage  indicesUsage,
std::span< const Vertex >  vertices,
std::span< const Index >  indices 
) &&
inline

Constructor for meshes that have a vertex buffer and an index buffer.

Parameters
verticesUsageintended access pattern of the vertex buffer, see MeshBufferUsage.
indicesUsageintended access pattern of the index buffer, see MeshBufferUsage.
verticesinitial data to copy into the vertex buffer.
indicesinitial data to copy into the index buffer.

◆ Mesh() [3/4]

template<typename Vertex , typename Index = NoIndex, typename Instance = NoInstance>
donut::graphics::Mesh< Vertex, Index, Instance >::Mesh ( MeshBufferUsage  verticesUsage,
MeshBufferUsage  instancesUsage,
std::span< const Vertex >  vertices,
std::span< const Instance >  instances 
) &&
inline

Constructor for meshes that have a vertex buffer and an instance buffer.

Parameters
verticesUsageintended access pattern of the vertex buffer, see MeshBufferUsage.
instancesUsageintended access pattern of the instance buffer, see MeshBufferUsage.
verticesinitial data to copy into the vertex buffer.
instancesinitial data to copy into the instance buffer.

◆ Mesh() [4/4]

template<typename Vertex , typename Index = NoIndex, typename Instance = NoInstance>
donut::graphics::Mesh< Vertex, Index, Instance >::Mesh ( MeshBufferUsage  verticesUsage,
MeshBufferUsage  indicesUsage,
MeshBufferUsage  instancesUsage,
std::span< const Vertex >  vertices,
std::span< const Index >  indices,
std::span< const Instance >  instances 
) &&
inline

Constructor for meshes that have a vertex buffer, an index buffer and an instance buffer.

Parameters
verticesUsageintended access pattern of the vertex buffer, see MeshBufferUsage.
indicesUsageintended access pattern of the index buffer, see MeshBufferUsage.
instancesUsageintended access pattern of the instance buffer, see MeshBufferUsage.
verticesinitial data to copy into the vertex buffer.
indicesinitial data to copy into the index buffer.
instancesinitial data to copy into the instance buffer.

Member Function Documentation

◆ setVertices() [1/2]

template<typename Vertex , typename Index = NoIndex, typename Instance = NoInstance>
void donut::graphics::Mesh< Vertex, Index, Instance >::setVertices ( MeshBufferUsage  verticesUsage,
std::span< const Vertex >  vertices 
)
inlinenoexcept

Set the contents of the vertex buffer.

Parameters
verticesUsagenew intended access pattern of the vertex buffer, see MeshBufferUsage.
verticesnew data to copy into the vertex buffer.
Note
The old contents of the buffer are discarded.

◆ setVertices() [2/2]

template<typename Vertex , typename Index = NoIndex, typename Instance = NoInstance>
void donut::graphics::Mesh< Vertex, Index, Instance >::setVertices ( MeshBufferUsage  verticesUsage,
MeshBufferUsage  indicesUsage,
std::span< const Vertex >  vertices,
std::span< const Index >  indices 
)
inlinenoexcept

Set the contents of the vertex and index buffers.

Parameters
verticesUsagenew intended access pattern of the vertex buffer, see MeshBufferUsage.
indicesUsagenew intended access pattern of the index buffer, see MeshBufferUsage.
verticesnew data to copy into the vertex buffer.
indicesnew data to copy into the index buffer.
Note
The old contents of the buffers are discarded.

◆ getVertexBuffer()

template<typename Vertex , typename Index = NoIndex, typename Instance = NoInstance>
Handle donut::graphics::Mesh< Vertex, Index, Instance >::getVertexBuffer ( ) const
inlinenoexcept

Get an opaque handle to the GPU representation of the vertex buffer.

Returns
a non-owning resource handle to the GPU representation of the vertex buffer.
Note
This function is used internally by the implementations of various abstractions and is not intended to be used outside of the graphics module. The returned handle has no meaning to application code.

◆ getIndexBuffer()

template<typename Vertex , typename Index = NoIndex, typename Instance = NoInstance>
Handle donut::graphics::Mesh< Vertex, Index, Instance >::getIndexBuffer ( ) const
inlinenoexcept

Get an opaque handle to the GPU representation of the index buffer.

Returns
a non-owning resource handle to the GPU representation of the index buffer.
Note
This function is used internally by the implementations of various abstractions and is not intended to be used outside of the graphics module. The returned handle has no meaning to application code.

◆ getInstanceBuffer()

template<typename Vertex , typename Index = NoIndex, typename Instance = NoInstance>
Handle donut::graphics::Mesh< Vertex, Index, Instance >::getInstanceBuffer ( ) const
inlinenoexcept

Get an opaque handle to the GPU representation of the instance buffer.

Returns
a non-owning resource handle to the GPU representation of the instance buffer.
Note
This function is used internally by the implementations of various abstractions and is not intended to be used outside of the graphics module. The returned handle has no meaning to application code.

◆ get()

template<typename Vertex , typename Index = NoIndex, typename Instance = NoInstance>
Handle donut::graphics::Mesh< Vertex, Index, Instance >::get ( ) const
inlinenoexcept

Get an opaque handle to the GPU representation of the vertex array.

Returns
a non-owning resource handle to the GPU representation of the vertex array.
Note
This function is used internally by the implementations of various abstractions and is not intended to be used outside of the graphics module. The returned handle has no meaning to application code.

Member Data Documentation

◆ IS_INDEXED

template<typename Vertex , typename Index = NoIndex, typename Instance = NoInstance>
constexpr bool donut::graphics::Mesh< Vertex, Index, Instance >::IS_INDEXED = !std::is_same_v<Index, NoIndex>
staticconstexpr

Tells if the mesh has an index buffer or not.

◆ IS_INSTANCED

template<typename Vertex , typename Index = NoIndex, typename Instance = NoInstance>
constexpr bool donut::graphics::Mesh< Vertex, Index, Instance >::IS_INSTANCED = !std::is_same_v<Instance, NoInstance>
staticconstexpr

Tells if the mesh has an instance buffer or not.


The documentation for this class was generated from the following file: