Monad Engine da02fba2
> Undercity Codex_
Loading...
Searching...
No Matches
mnd::Mesh Class Reference

Immutable GPU mesh (VAO + VBO + optional EBO). More...

#include <Mesh.h>

Public Member Functions

 Mesh (const VertexLayout &layout, const std::vector< float > &vertices, const std::vector< uint32_t > &indices)
 Upload indexed geometry to the GPU.
 
 Mesh (const VertexLayout &layout, const std::vector< float > &vertices)
 Upload non-indexed geometry to the GPU.
 
 Mesh (const Mesh &)=delete
 
Meshoperator= (const Mesh &)=delete
 
void Bind ()
 Bind the VAO so subsequent draw calls use this mesh's geometry.
 
void Unbind ()
 
void Draw ()
 Issue the draw call for this mesh.
 

Static Public Member Functions

static std::shared_ptr< MeshCreateCube ()
 Creates a unit cube mesh (factory convenience, same as Builder::CreateCube).
 
static std::shared_ptr< MeshCreateSphere (f32 radius, int sectors, int stacks)
 
static std::shared_ptr< MeshCreateCapsule (f32 radius, f32 height, int sectors, int hemisphereStacks)
 
static std::shared_ptr< MeshCreateBox (const glm::vec3 &extents=glm::vec3(1.0f))
 

Detailed Description

Immutable GPU mesh (VAO + VBO + optional EBO).

Non-copyable — each instance owns unique GL handles. Vertex data is uploaded to the GPU in the constructor and released from CPU memory immediately; the GL objects live until the Mesh is destroyed.

Definition at line 42 of file Mesh.h.

Constructor & Destructor Documentation

◆ Mesh() [1/3]

mnd::Mesh::Mesh ( const VertexLayout layout,
const std::vector< float > &  vertices,
const std::vector< uint32_t > &  indices 
)

Upload indexed geometry to the GPU.

Parameters
layoutDescribes how vertex bytes map to shader attributes.
verticesInterleaved vertex data (position, normal, UV …).
indicesTriangle list indices into the vertex array.

Definition at line 50 of file Mesh.cpp.

References mnd::VertexLayout::elements, mnd::Engine::GetGraphicsAPI(), mnd::Engine::GetInstance(), LOG_INFO, and mnd::VertexLayout::stride.

◆ Mesh() [2/3]

mnd::Mesh::Mesh ( const VertexLayout layout,
const std::vector< float > &  vertices 
)

Upload non-indexed geometry to the GPU.

Parameters
layoutVertex attribute layout.
verticesInterleaved vertex data; drawn with glDrawArrays.

Definition at line 167 of file Mesh.cpp.

References mnd::VertexLayout::elements, mnd::Engine::GetGraphicsAPI(), mnd::Engine::GetInstance(), LOG_INFO, and mnd::VertexLayout::stride.

◆ Mesh() [3/3]

mnd::Mesh::Mesh ( const Mesh )
delete

Member Function Documentation

◆ Bind()

void mnd::Mesh::Bind ( )

Bind the VAO so subsequent draw calls use this mesh's geometry.

Definition at line 193 of file Mesh.cpp.

◆ CreateBox()

std::shared_ptr< Mesh > mnd::Mesh::CreateBox ( const glm::vec3 &  extents = glm::vec3(1.0f))
static

◆ CreateCapsule()

std::shared_ptr< Mesh > mnd::Mesh::CreateCapsule ( f32  radius,
f32  height,
int  sectors,
int  hemisphereStacks 
)
static

◆ CreateCube()

std::shared_ptr< Mesh > mnd::Mesh::CreateCube ( )
static

◆ CreateSphere()

std::shared_ptr< Mesh > mnd::Mesh::CreateSphere ( f32  radius,
int  sectors,
int  stacks 
)
static

◆ Draw()

void mnd::Mesh::Draw ( )

Issue the draw call for this mesh.

Uses glDrawElements when an EBO is present; glDrawArrays otherwise. Must be preceded by Bind() (or GraphicsAPI::BindMesh()).

Definition at line 198 of file Mesh.cpp.

◆ operator=()

Mesh & mnd::Mesh::operator= ( const Mesh )
delete

◆ Unbind()

void mnd::Mesh::Unbind ( )

Definition at line 317 of file Mesh.cpp.


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