Chira Engine
A customizable MIT-licensed game engine.
MeshData.h
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 #include <loader/mesh/IMeshLoader.h>
6 #include <render/backend/RenderTypes.h>
7 #include <render/material/MaterialFactory.h>
8 
9 namespace chira {
10 
11 class MeshData {
12 public:
13  MeshData() = default;
14  void render(glm::mat4 model, MeshCullType cullType = MeshCullType::BACK);
15  virtual ~MeshData();
16  [[nodiscard]] SharedPointer<IMaterial> getMaterial() const;
17  void setMaterial(SharedPointer<IMaterial> newMaterial);
18  [[nodiscard]] MeshDepthFunction getDepthFunction() const;
19  void setDepthFunction(MeshDepthFunction function);
20  [[nodiscard]] std::vector<byte> getMeshData(const std::string& meshLoader) const;
21  void appendMeshData(const std::string& loader, const std::string& identifier);
22 protected:
23  bool initialized = false;
24  Renderer::MeshHandle handle{};
25  MeshDrawMode drawMode = MeshDrawMode::STATIC;
26  MeshDepthFunction depthFunction = MeshDepthFunction::LEQUAL;
27  SharedPointer<IMaterial> material;
28  std::vector<Vertex> vertices;
29  std::vector<Index> indices;
31  void setupForRendering();
33  void updateMeshData();
35  void clearMeshData();
36 };
37 
38 } // namespace chira
void updateMeshData()
Updates the vertex buffers with the current mesh data.
Definition: MeshData.cpp:15
void setupForRendering()
Establishes the vertex buffers and copies the current mesh data into them.
Definition: MeshData.cpp:10
void clearMeshData()
Does not call updateMeshData().
Definition: MeshData.cpp:62