MAGE  v0.171.0
Matthias Advanced Game Engine
mage::rendering::Mesh Class Reference

#include <mesh.hpp>

Inheritance diagram for mage::rendering::Mesh:
mage::rendering::PrimitiveBatchMesh< VertexT, IndexT > mage::rendering::StaticMesh< VertexT, IndexT > mage::rendering::PrimitiveBatchMesh< VertexPositionColorTexture, U16 > mage::rendering::SpriteBatchMesh

Public Member Functions

virtual ~Mesh ()
 
Meshoperator= (const Mesh &mesh)=delete
 
Meshoperator= (Mesh &&mesh) noexcept
 
std::size_t GetNumberOfVertices () const noexcept
 
std::size_t GetNumberOfIndices () const noexcept
 
std::size_t GetVertexSize () const noexcept
 
DXGI_FORMAT GetIndexFormat () const noexcept
 
D3D11_PRIMITIVE_TOPOLOGY GetPrimitiveTopology () const noexcept
 
void BindMesh (ID3D11DeviceContext &device_context) const noexcept
 
void BindMesh (ID3D11DeviceContext &device_context, D3D11_PRIMITIVE_TOPOLOGY topology) const noexcept
 
void Draw (ID3D11DeviceContext &device_context) const noexcept
 
void Draw (ID3D11DeviceContext &device_context, std::size_t start_index, std::size_t nb_indices) const noexcept
 

Protected Member Functions

 Mesh (std::size_t vertex_size, DXGI_FORMAT index_format, D3D11_PRIMITIVE_TOPOLOGY primitive_topology)
 
 Mesh (const Mesh &mesh)=delete
 
 Mesh (Mesh &&mesh) noexcept
 
void SetNumberOfVertices (std::size_t nb_vertices) noexcept
 
void SetNumberOfIndices (std::size_t nb_indices) noexcept
 

Protected Attributes

ComPtr< ID3D11Buffer > m_vertex_buffer
 
ComPtr< ID3D11Buffer > m_index_buffer
 

Private Attributes

std::size_t m_nb_vertices
 
std::size_t m_nb_indices
 
std::size_t m_vertex_size
 
DXGI_FORMAT m_index_format
 
D3D11_PRIMITIVE_TOPOLOGY m_primitive_topology
 

Detailed Description

A class of indexed meshes.

Constructor & Destructor Documentation

◆ ~Mesh()

mage::rendering::Mesh::~Mesh ( )
virtualdefault

Destructs this mesh.

◆ Mesh() [1/3]

mage::rendering::Mesh::Mesh ( std::size_t  vertex_size,
DXGI_FORMAT  index_format,
D3D11_PRIMITIVE_TOPOLOGY  primitive_topology 
)
explicitprotected

Constructs a mesh.

Parameters
[in]vertex_sizeThe vertex size.
[in]index_formatThe index format.
[in]primitive_topologyThe primitive topology.

◆ Mesh() [2/3]

mage::rendering::Mesh::Mesh ( const Mesh mesh)
protecteddelete

Constructs a mesh from the given mesh.

Parameters
[in]meshA reference to the mesh to copy.

◆ Mesh() [3/3]

mage::rendering::Mesh::Mesh ( Mesh &&  mesh)
protecteddefaultnoexcept

Constructs a mesh by moving the given mesh.

Parameters
[in]meshA reference to the mesh to move.

Member Function Documentation

◆ BindMesh() [1/2]

void mage::rendering::Mesh::BindMesh ( ID3D11DeviceContext &  device_context) const
noexcept

Binds this mesh.

The vertex buffer, index buffer and primitive topology of this mesh will be bound to the input-assembler stage.

Parameters
[in,out]device_contextA reference to the device context.

◆ BindMesh() [2/2]

void mage::rendering::Mesh::BindMesh ( ID3D11DeviceContext &  device_context,
D3D11_PRIMITIVE_TOPOLOGY  topology 
) const
noexcept

Binds this mesh with given primitive topology.

The vertex buffer, index buffer and given primitive topology of this mesh will be bound to the input-assembler stage.

Parameters
[in,out]device_contextA reference to the device context.
[in]topologyThe primitive topology.

◆ Draw() [1/2]

void mage::rendering::Mesh::Draw ( ID3D11DeviceContext &  device_context) const
noexcept

Draws this complete mesh.

Parameters
[in,out]device_contextA reference to the device context.

◆ Draw() [2/2]

void mage::rendering::Mesh::Draw ( ID3D11DeviceContext &  device_context,
std::size_t  start_index,
std::size_t  nb_indices 
) const
noexcept

Draws a submesh of this mesh.

Parameters
[in,out]device_contextA reference to the device context.
[in]start_indexThe start index.
[in]nb_indicesThe number of indices.

◆ GetIndexFormat()

DXGI_FORMAT mage::rendering::Mesh::GetIndexFormat ( ) const
noexcept

Returns the index format of this mesh.

Returns
The index format of this mesh.

◆ GetNumberOfIndices()

std::size_t mage::rendering::Mesh::GetNumberOfIndices ( ) const
noexcept

Returns the number of indices of this mesh.

Returns
The number of indices of this mesh.

◆ GetNumberOfVertices()

std::size_t mage::rendering::Mesh::GetNumberOfVertices ( ) const
noexcept

Returns the number of vertices of this mesh.

Returns
The number of vertices of this mesh.

◆ GetPrimitiveTopology()

D3D11_PRIMITIVE_TOPOLOGY mage::rendering::Mesh::GetPrimitiveTopology ( ) const
noexcept

Returns the primitive topology of this mesh.

Returns
The primitive topology of this mesh.

◆ GetVertexSize()

std::size_t mage::rendering::Mesh::GetVertexSize ( ) const
noexcept

Returns the size (in bytes) of the vertices of this mesh.

Returns
The vertex size (in bytes) of this mesh.

◆ operator=() [1/2]

Mesh& mage::rendering::Mesh::operator= ( const Mesh mesh)
delete

Copies the given mesh to this mesh.

Parameters
[in]meshA reference to the mesh to copy.
Returns
A reference to the copy of the given mesh (i.e. this mesh).

◆ operator=() [2/2]

Mesh & mage::rendering::Mesh::operator= ( Mesh &&  mesh)
defaultnoexcept

Moves the given mesh to this mesh.

Parameters
[in]meshA reference to the mesh to move.
Returns
A reference to the moved mesh (i.e. this mesh).

◆ SetNumberOfIndices()

void mage::rendering::Mesh::SetNumberOfIndices ( std::size_t  nb_indices)
protectednoexcept

Sets the number of indices of this mesh to the given number.

Parameters
[in]nb_indicesThe number of indices of this mesh.

◆ SetNumberOfVertices()

void mage::rendering::Mesh::SetNumberOfVertices ( std::size_t  nb_vertices)
protectednoexcept

Sets the number of vertices of this mesh to the given number.

Parameters
[in]nb_verticesThe number of vertices of this mesh.

Member Data Documentation

◆ m_index_buffer

ComPtr< ID3D11Buffer > mage::rendering::Mesh::m_index_buffer
protected

A pointer to the index buffer of this mesh.

◆ m_index_format

DXGI_FORMAT mage::rendering::Mesh::m_index_format
private

The index format of this mesh.

◆ m_nb_indices

std::size_t mage::rendering::Mesh::m_nb_indices
private

The number of indices of this mesh.

◆ m_nb_vertices

std::size_t mage::rendering::Mesh::m_nb_vertices
private

The number of vertices of this mesh.

◆ m_primitive_topology

D3D11_PRIMITIVE_TOPOLOGY mage::rendering::Mesh::m_primitive_topology
private

The primitive topology of this mesh.

◆ m_vertex_buffer

ComPtr< ID3D11Buffer > mage::rendering::Mesh::m_vertex_buffer
protected

A pointer to the vertex buffer of this mesh.

◆ m_vertex_size

std::size_t mage::rendering::Mesh::m_vertex_size
private

The vertex size of this mesh.