GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::graphics::Mesh< Vertex, Index, Parameters, Instance > Class Template Reference

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

#include <GREM/graphics/Mesh.hpp>

Inheritance diagram for grem::graphics::Mesh< Vertex, Index, Parameters, Instance >:

Public Types

using vertex_type = Vertex
 Vertex type of the mesh.
using index_type = Index
 Index type of the mesh.
using parameters_type = Parameters
 Parameters type of the mesh.
using instance_type = Instance
 Instance type of the mesh.

Public Member Functions

 Mesh (Device &device, VertexAttributeMask activeVertexAttributes=~VertexAttributeMask{})
 Construct an empty mesh.
 Mesh (Device &device, const Parameters &parameters, VertexAttributeMask activeVertexAttributes=~VertexAttributeMask{})
 Construct an empty mesh.
 Mesh (Device &device, Span< const Vertex > vertices, VertexAttributeMask activeVertexAttributes=~VertexAttributeMask{})
 Constructor for meshes that only have a vertex buffer.
 Mesh (Device &device, Span< const Vertex > vertices, Span< const Index > indices, VertexAttributeMask activeVertexAttributes=~VertexAttributeMask{})
 Constructor for meshes that have a vertex buffer and an index buffer.
 Mesh (Device &device, Span< const Vertex > vertices, const Parameters &parameters, VertexAttributeMask activeVertexAttributes=~VertexAttributeMask{})
 Constructor for meshes that have a vertex buffer and a uniform buffer.
 Mesh (Device &device, Span< const Vertex > vertices, Span< const Index > indices, const Parameters &parameters, VertexAttributeMask activeVertexAttributes=~VertexAttributeMask{})
 Constructor for meshes that have a vertex buffer, an index buffer and a uniform buffer.
void setVertices (Span< const Vertex > newVertices) noexcept
 Upload new vertices to the vertex buffer, overriding any previous contents.
template<typename... AttributeArrays>
requires (sizeof...(AttributeArrays) == meta::aggregate_size_v<Vertex>)
void setVertexAttributes (const AttributeArrays &... vertexAttributes) noexcept
 Upload new deinterleaved vertex attributes to the vertex buffer, overriding any previous contents.
void setIndices (Span< const Index > newIndices) noexcept
 Upload new indices to the index buffer, overriding any previous contents.
void setVerticesAndIndices (Span< const Vertex > newVertices, Span< const Index > newIndices) noexcept
 Upload new vertices and indices to the vertex and index buffers, overriding any previous contents.
template<typename... AttributeArrays>
requires (!same_as<Index, NoIndex> && sizeof...(AttributeArrays) == meta::aggregate_size_v<Vertex>)
void setIndicesAndVertexAttributes (Span< const Index > newIndices, const AttributeArrays &... vertexAttributes) noexcept
 Upload new indices and deinterleaved vertex attributes to the index and vertex buffers, overriding any previous contents.
void setParameters (const Parameters &newParameters) noexcept
 Upload new parameter values to the uniform buffer, overriding any previous contents.

Detailed Description

template<typename Vertex, typename Index = NoIndex, typename Parameters = NoParameters, typename Instance = NoInstance>
class grem::graphics::Mesh< Vertex, Index, Parameters, 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 grem::graphics::mesh_vertex concept.
Indextype of indices stored in the index buffer, or NoIndex for no index buffer. Must meet the requirements of the grem::graphics::mesh_index concept.
Parametersuser-defined aggregate type of parameters that the uniform buffer of the mesh should contain.
Instancetype of instances stored in the instance buffer, or NoInstance for no instance buffer. Must meet the requirements of the grem::graphics::mesh_instance concept.

Member Typedef Documentation

◆ vertex_type

template<typename Vertex, typename Index = NoIndex, typename Parameters = NoParameters, typename Instance = NoInstance>
using grem::graphics::Mesh< Vertex, Index, Parameters, Instance >::vertex_type = Vertex

Vertex type of the mesh.

◆ index_type

template<typename Vertex, typename Index = NoIndex, typename Parameters = NoParameters, typename Instance = NoInstance>
using grem::graphics::Mesh< Vertex, Index, Parameters, Instance >::index_type = Index

Index type of the mesh.

◆ parameters_type

template<typename Vertex, typename Index = NoIndex, typename Parameters = NoParameters, typename Instance = NoInstance>
using grem::graphics::Mesh< Vertex, Index, Parameters, Instance >::parameters_type = Parameters

Parameters type of the mesh.

◆ instance_type

template<typename Vertex, typename Index = NoIndex, typename Parameters = NoParameters, typename Instance = NoInstance>
using grem::graphics::Mesh< Vertex, Index, Parameters, Instance >::instance_type = Instance

Instance type of the mesh.

Constructor & Destructor Documentation

◆ Mesh() [1/6]

template<typename Vertex, typename Index = NoIndex, typename Parameters = NoParameters, typename Instance = NoInstance>
grem::graphics::Mesh< Vertex, Index, Parameters, Instance >::Mesh ( Device & device,
VertexAttributeMask activeVertexAttributes = ~VertexAttributeMask{} )
inline

Construct an empty mesh.

Parameters
devicedevice to create the mesh for. Must outlive the mesh.
activeVertexAttributesmask of active vertex attributes for this mesh. Inactive vertex attributes must not be read by any shader that receives this mesh as input.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ Mesh() [2/6]

template<typename Vertex, typename Index = NoIndex, typename Parameters = NoParameters, typename Instance = NoInstance>
grem::graphics::Mesh< Vertex, Index, Parameters, Instance >::Mesh ( Device & device,
const Parameters & parameters,
VertexAttributeMask activeVertexAttributes = ~VertexAttributeMask{} )
inline

Construct an empty mesh.

Parameters
devicedevice to create the mesh for. Must outlive the mesh.
parametersinitial parameter values to upload to the uniform buffer.
activeVertexAttributesmask of active vertex attributes for this mesh. Inactive vertex attributes must not be read by any shader that receives this mesh as input.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ Mesh() [3/6]

template<typename Vertex, typename Index = NoIndex, typename Parameters = NoParameters, typename Instance = NoInstance>
grem::graphics::Mesh< Vertex, Index, Parameters, Instance >::Mesh ( Device & device,
Span< const Vertex > vertices,
VertexAttributeMask activeVertexAttributes = ~VertexAttributeMask{} )
inline

Constructor for meshes that only have a vertex buffer.

Parameters
devicedevice to create the mesh for. Must outlive the mesh.
verticesinitial data to upload to the vertex buffer.
activeVertexAttributesmask of active vertex attributes for this mesh. Inactive vertex attributes must not be read by any shader that receives this mesh as input.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ Mesh() [4/6]

template<typename Vertex, typename Index = NoIndex, typename Parameters = NoParameters, typename Instance = NoInstance>
grem::graphics::Mesh< Vertex, Index, Parameters, Instance >::Mesh ( Device & device,
Span< const Vertex > vertices,
Span< const Index > indices,
VertexAttributeMask activeVertexAttributes = ~VertexAttributeMask{} )
inline

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

Parameters
devicedevice to create the mesh for. Must outlive the mesh.
verticesinitial data to upload to the vertex buffer.
indicesinitial data to upload to the index buffer.
activeVertexAttributesmask of active vertex attributes for this mesh. Inactive vertex attributes must not be read by any shader that receives this mesh as input.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ Mesh() [5/6]

template<typename Vertex, typename Index = NoIndex, typename Parameters = NoParameters, typename Instance = NoInstance>
grem::graphics::Mesh< Vertex, Index, Parameters, Instance >::Mesh ( Device & device,
Span< const Vertex > vertices,
const Parameters & parameters,
VertexAttributeMask activeVertexAttributes = ~VertexAttributeMask{} )
inline

Constructor for meshes that have a vertex buffer and a uniform buffer.

Parameters
devicedevice to create the mesh for. Must outlive the mesh.
verticesinitial data to upload to the vertex buffer.
parametersinitial parameter values to upload to the uniform buffer.
activeVertexAttributesmask of active vertex attributes for this mesh. Inactive vertex attributes must not be read by any shader that receives this mesh as input.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ Mesh() [6/6]

template<typename Vertex, typename Index = NoIndex, typename Parameters = NoParameters, typename Instance = NoInstance>
grem::graphics::Mesh< Vertex, Index, Parameters, Instance >::Mesh ( Device & device,
Span< const Vertex > vertices,
Span< const Index > indices,
const Parameters & parameters,
VertexAttributeMask activeVertexAttributes = ~VertexAttributeMask{} )
inline

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

Parameters
devicedevice to create the mesh for. Must outlive the mesh.
verticesinitial data to copy into the vertex buffer.
indicesinitial data to copy into the index buffer.
parametersinitial parameter values to upload to the uniform buffer.
activeVertexAttributesmask of active vertex attributes for this mesh. Inactive vertex attributes must not be read by any shader that receives this mesh as input.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

Member Function Documentation

◆ setVertices()

template<typename Vertex, typename Index = NoIndex, typename Parameters = NoParameters, typename Instance = NoInstance>
void grem::graphics::Mesh< Vertex, Index, Parameters, Instance >::setVertices ( Span< const Vertex > newVertices)
inlinenoexcept

Upload new vertices to the vertex buffer, overriding any previous contents.

Parameters
newVerticesnew data to upload to the vertex buffer.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ setVertexAttributes()

template<typename Vertex, typename Index = NoIndex, typename Parameters = NoParameters, typename Instance = NoInstance>
template<typename... AttributeArrays>
requires (sizeof...(AttributeArrays) == meta::aggregate_size_v<Vertex>)
void grem::graphics::Mesh< Vertex, Index, Parameters, Instance >::setVertexAttributes ( const AttributeArrays &... vertexAttributes)
inlinenoexcept

Upload new deinterleaved vertex attributes to the vertex buffer, overriding any previous contents.

Parameters
vertexAttributesnew arrays of attribute values to upload to the vertex buffer. Each attribute array must either be empty or have the same size as all other non-empty arrays. If a given array is empty, its corresponding vertex attribute must have been specified as inactive in the mesh constructor.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ setIndices()

template<typename Vertex, typename Index = NoIndex, typename Parameters = NoParameters, typename Instance = NoInstance>
void grem::graphics::Mesh< Vertex, Index, Parameters, Instance >::setIndices ( Span< const Index > newIndices)
inlinenoexcept

Upload new indices to the index buffer, overriding any previous contents.

Parameters
newIndicesnew data to upload to the index buffer.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ setVerticesAndIndices()

template<typename Vertex, typename Index = NoIndex, typename Parameters = NoParameters, typename Instance = NoInstance>
void grem::graphics::Mesh< Vertex, Index, Parameters, Instance >::setVerticesAndIndices ( Span< const Vertex > newVertices,
Span< const Index > newIndices )
inlinenoexcept

Upload new vertices and indices to the vertex and index buffers, overriding any previous contents.

Parameters
newVerticesnew data to upload to the vertex buffer.
newIndicesnew data to upload to the index buffer.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ setIndicesAndVertexAttributes()

template<typename Vertex, typename Index = NoIndex, typename Parameters = NoParameters, typename Instance = NoInstance>
template<typename... AttributeArrays>
requires (!same_as<Index, NoIndex> && sizeof...(AttributeArrays) == meta::aggregate_size_v<Vertex>)
void grem::graphics::Mesh< Vertex, Index, Parameters, Instance >::setIndicesAndVertexAttributes ( Span< const Index > newIndices,
const AttributeArrays &... vertexAttributes )
inlinenoexcept

Upload new indices and deinterleaved vertex attributes to the index and vertex buffers, overriding any previous contents.

Parameters
newIndicesnew data to upload to the index buffer.
vertexAttributesnew arrays of attribute values to upload to the vertex buffer. Each attribute array must either be empty or have the same size as all other non-empty arrays. If a given array is empty, its corresponding vertex attribute must have been specified as inactive in the mesh constructor.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ setParameters()

template<typename Vertex, typename Index = NoIndex, typename Parameters = NoParameters, typename Instance = NoInstance>
void grem::graphics::Mesh< Vertex, Index, Parameters, Instance >::setParameters ( const Parameters & newParameters)
inlinenoexcept

Upload new parameter values to the uniform buffer, overriding any previous contents.

Parameters
newParametersnew parameter values to upload.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

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