![]() |
Rendering Engine 0.2.0
Modular Graphics Rendering Engine | v0.2.0
|
Manages mesh data in RAM and GPU, including upload and release operations. More...
#include <mesh_data_gpu.hpp>
Public Member Functions | |
| MeshDataGpu (IRenderer *renderer) | |
| Constructs an empty MeshDataGpu object. | |
| MeshDataGpu (const std::string &filename, IRenderer *renderer) | |
| Construct a MeshDataGpu instance. | |
| MeshDataGpu (std::vector< uint8_t > const &fileBytes, IRenderer *renderer) | |
| Constructs a MeshDataGpu instance from in-memory model data. | |
| ~MeshDataGpu () | |
| Destructor. Releases GPU resources if allocated. | |
| void | UploadToGPU () |
| Upload mesh data to the GPU using the current mesh type. | |
| void | ReleaseFromGPU () |
| Release GPU resources associated with this mesh. | |
| bool | IsOnGPU () const |
| Check if mesh data is currently uploaded to GPU. | |
| void | CreateQuad2D () |
| Creates a 1�1 unit quad centered at the origin. | |
| size_t | GetGpuVertexBufferSize () const |
| Get the size (in bytes) of the vertex buffer on GPU. | |
| size_t | GetGpuIndexBufferSize () const |
| Get the size (in bytes) of the index buffer on GPU. | |
| size_t | GetCpuVertexBufferSize () const |
| Get the size (in bytes) of the vertex buffer in RAM. | |
| size_t | GetCpuIndexBufferSize () const |
| Get the size (in bytes) of the index buffer in RAM. | |
| IMeshRenderResources * | GetMeshRenderResources () |
| Get the interface for mesh GPU resources (Vulkan or other backend). | |
| const std::vector< glm::vec2 > & | GetPositions2D () const |
| Returns a constant reference to the 2D vertex positions. | |
| const std::vector< glm::vec3 > & | GetPositions () const |
| Returns a constant reference to the 3D vertex positions. | |
| const std::vector< glm::vec4 > & | GetColors () const |
| Returns a constant reference to the vertex colors. | |
| const std::vector< glm::vec3 > & | GetNormals () const |
| Returns a constant reference to the vertex normals. | |
| const std::vector< glm::vec2 > & | GetTexCoords () const |
| Returns a constant reference to the texture coordinates. | |
| const std::vector< glm::vec3 > & | GetTangents () const |
| Returns a constant reference to the vertex tangents. | |
| const std::vector< uint32_t > & | GetIndices () const |
| Returns a constant reference to the mesh indices. | |
Protected Member Functions | |
| void | LoadModel (std::string path) |
| Load a model from file and extract mesh data to RAM. | |
| void | LoadModel (std::vector< uint8_t > const &fileBytes) |
| void | CalculateMeshParameters () |
| Calculate and cache sizes of RAM buffers for statistics or debugging. | |
| std::vector< Vertex2D > | ComposeVertex2DBuffer () |
| Compose a vertex buffer for 2D meshes (e.g., sprites). | |
| std::vector< VertexPositionColorTexture > | ComposeUnlitBuffer () |
| Compose a vertex buffer for unlit 3D meshes (e.g., billboards, particles). | |
| std::vector< VertexPositionColorTextureNormalTangent > | ComposeLitBuffer () |
| Compose a vertex buffer for lit 3D meshes (with normals, tangents). | |
Manages mesh data in RAM and GPU, including upload and release operations.
Supports on-demand composition of different vertex buffer formats and maintains all intermediate mesh data required for rendering or further processing (e.g., collision).
Definition at line 36 of file mesh_data_gpu.hpp.
| rendering_engine::MeshDataGpu::MeshDataGpu | ( | IRenderer * | renderer | ) |
Constructs an empty MeshDataGpu object.
This constructor is typically used when the mesh data will be filled or generated procedurally before being uploaded to the GPU.
| renderer | Pointer to the rendering backend interface. |
Definition at line 8 of file mesh_data_gpu.cpp.
| rendering_engine::MeshDataGpu::MeshDataGpu | ( | const std::string & | filename, |
| IRenderer * | renderer ) |
Construct a MeshDataGpu instance.
| filename | Path to the model file |
| renderer | Pointer to the rendering backend interface. |
Definition at line 17 of file mesh_data_gpu.cpp.
| rendering_engine::MeshDataGpu::MeshDataGpu | ( | std::vector< uint8_t > const & | fileBytes, |
| IRenderer * | renderer ) |
Constructs a MeshDataGpu instance from in-memory model data.
This version loads a model directly from a raw file buffer in memory. It allows meshes to be created from packed assets, archives, network transfers, or any other non-filesystem source. After loading the model, vertex and index data are uploaded to GPU buffers the same way as in the file-based constructor.
| fileBytes | Raw contents of the model file. |
| renderer | Pointer to the rendering backend interface. |
Definition at line 28 of file mesh_data_gpu.cpp.
| rendering_engine::MeshDataGpu::~MeshDataGpu | ( | ) |
Destructor. Releases GPU resources if allocated.
Definition at line 39 of file mesh_data_gpu.cpp.
|
protected |
Calculate and cache sizes of RAM buffers for statistics or debugging.
Definition at line 229 of file mesh_data_gpu.cpp.
|
protected |
Compose a vertex buffer for lit 3D meshes (with normals, tangents).
Definition at line 285 of file mesh_data_gpu.cpp.
|
protected |
Compose a vertex buffer for unlit 3D meshes (e.g., billboards, particles).
Definition at line 266 of file mesh_data_gpu.cpp.
|
protected |
Compose a vertex buffer for 2D meshes (e.g., sprites).
Definition at line 247 of file mesh_data_gpu.cpp.
| void rendering_engine::MeshDataGpu::CreateQuad2D | ( | ) |
Creates a 1�1 unit quad centered at the origin.
The quad spans from -0.5 to +0.5 on both X and Y axes and uses counterclockwise winding. Suitable as a base mesh for sprites or 2D UI elements.
Definition at line 171 of file mesh_data_gpu.cpp.
|
inline |
Returns a constant reference to the vertex colors.
Definition at line 142 of file mesh_data_gpu.hpp.
| size_t rendering_engine::MeshDataGpu::GetCpuIndexBufferSize | ( | ) | const |
Get the size (in bytes) of the index buffer in RAM.
Definition at line 215 of file mesh_data_gpu.cpp.
| size_t rendering_engine::MeshDataGpu::GetCpuVertexBufferSize | ( | ) | const |
Get the size (in bytes) of the vertex buffer in RAM.
Definition at line 210 of file mesh_data_gpu.cpp.
| size_t rendering_engine::MeshDataGpu::GetGpuIndexBufferSize | ( | ) | const |
Get the size (in bytes) of the index buffer on GPU.
Definition at line 198 of file mesh_data_gpu.cpp.
| size_t rendering_engine::MeshDataGpu::GetGpuVertexBufferSize | ( | ) | const |
Get the size (in bytes) of the vertex buffer on GPU.
Definition at line 186 of file mesh_data_gpu.cpp.
|
inline |
Returns a constant reference to the mesh indices.
Definition at line 162 of file mesh_data_gpu.hpp.
| IMeshRenderResources * rendering_engine::MeshDataGpu::GetMeshRenderResources | ( | ) |
Get the interface for mesh GPU resources (Vulkan or other backend).
Definition at line 220 of file mesh_data_gpu.cpp.
|
inline |
Returns a constant reference to the vertex normals.
Definition at line 147 of file mesh_data_gpu.hpp.
|
inline |
Returns a constant reference to the 3D vertex positions.
Definition at line 137 of file mesh_data_gpu.hpp.
|
inline |
Returns a constant reference to the 2D vertex positions.
Definition at line 132 of file mesh_data_gpu.hpp.
|
inline |
Returns a constant reference to the vertex tangents.
Definition at line 157 of file mesh_data_gpu.hpp.
|
inline |
Returns a constant reference to the texture coordinates.
Definition at line 152 of file mesh_data_gpu.hpp.
| bool rendering_engine::MeshDataGpu::IsOnGPU | ( | ) | const |
Check if mesh data is currently uploaded to GPU.
Definition at line 103 of file mesh_data_gpu.cpp.
|
protected |
Load a model from file and extract mesh data to RAM.
| path | Path to the model file (e.g., FBX). |
Definition at line 115 of file mesh_data_gpu.cpp.
|
protected |
Definition at line 143 of file mesh_data_gpu.cpp.
| void rendering_engine::MeshDataGpu::ReleaseFromGPU | ( | ) |
Release GPU resources associated with this mesh.
Definition at line 87 of file mesh_data_gpu.cpp.
| void rendering_engine::MeshDataGpu::UploadToGPU | ( | ) |
Upload mesh data to the GPU using the current mesh type.
Definition at line 44 of file mesh_data_gpu.cpp.