|
Monad Engine da02fba2
> Undercity Codex_
|
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 | |
| Mesh & | operator= (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< Mesh > | CreateCube () |
| Creates a unit cube mesh (factory convenience, same as Builder::CreateCube). | |
| static std::shared_ptr< Mesh > | CreateSphere (f32 radius, int sectors, int stacks) |
| static std::shared_ptr< Mesh > | CreateCapsule (f32 radius, f32 height, int sectors, int hemisphereStacks) |
| static std::shared_ptr< Mesh > | CreateBox (const glm::vec3 &extents=glm::vec3(1.0f)) |
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.
| mnd::Mesh::Mesh | ( | const VertexLayout & | layout, |
| const std::vector< float > & | vertices, | ||
| const std::vector< uint32_t > & | indices | ||
| ) |
Upload indexed geometry to the GPU.
| layout | Describes how vertex bytes map to shader attributes. |
| vertices | Interleaved vertex data (position, normal, UV …). |
| indices | Triangle 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.
| mnd::Mesh::Mesh | ( | const VertexLayout & | layout, |
| const std::vector< float > & | vertices | ||
| ) |
Upload non-indexed geometry to the GPU.
| layout | Vertex attribute layout. |
| vertices | Interleaved 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.
|
delete |
| void mnd::Mesh::Bind | ( | ) |
|
static |
Definition at line 209 of file Mesh.cpp.
References mnd::VertexElement::ColorIndex, mnd::VertexLayout::elements, kStandardVertexFloats, mnd::VertexElement::NormalIndex, mnd::VertexElement::PositionIndex, mnd::VertexLayout::stride, and mnd::VertexElement::UVIndex.
Referenced by mnd::MeshComponent::LoadProperties().
|
static |
Definition at line 396 of file Mesh.cpp.
References mnd::VertexLayout::elements, kPI, mnd::VertexElement::NormalIndex, mnd::VertexElement::PositionIndex, mnd::VertexLayout::stride, and mnd::VertexElement::UVIndex.
|
static |
Creates a unit cube mesh (factory convenience, same as Builder::CreateCube).
Definition at line 81 of file Mesh.cpp.
References mnd::VertexElement::ColorIndex, mnd::VertexLayout::elements, kStandardVertexFloats, mnd::VertexElement::NormalIndex, mnd::VertexElement::PositionIndex, mnd::VertexLayout::stride, and mnd::VertexElement::UVIndex.
Definition at line 322 of file Mesh.cpp.
References mnd::VertexLayout::elements, kPI, mnd::VertexElement::NormalIndex, mnd::VertexElement::PositionIndex, mnd::VertexLayout::stride, and mnd::VertexElement::UVIndex.
Referenced by mnd::MeshComponent::LoadProperties().
| 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()).