Midnight Graphics
Create Fast and Simple Graphics in C++
Mesh.hpp
1 #pragma once
2 
3 #include <Def.hpp>
4 #include <Math.hpp>
5 
6 namespace mn::Graphics
7 {
8  template<typename T>
9  struct TypeBuffer;
10  struct RenderFrame;
11 
12  struct Mesh
13  {
14  friend struct RenderFrame;
15 
16  struct Vertex
17  {
18  mn::Math::Vec3f position, normal;
19  mn::Math::Vec4f color;
20  mn::Math::Vec2f tex_coords;
21  };
22 
23  struct Frame
24  {
25  std::vector<Vertex> vertices;
26  std::vector<uint32_t> indices;
27  };
28 
29  MN_SYMBOL static Mesh fromFrame(const Frame& frame);
30  MN_SYMBOL static Mesh fromLua(const std::string& lua_file);
31 
32  MN_SYMBOL std::size_t vertexCount() const;
33  MN_SYMBOL std::size_t indexCount() const;
34 
35  MN_SYMBOL void setVertexCount(uint32_t count);
36  MN_SYMBOL void setIndexCount(uint32_t count);
37 
38  MN_SYMBOL std::span<Vertex> vertices();
39  MN_SYMBOL std::span<const Vertex> vertices() const;
40 
41  MN_SYMBOL std::span<uint32_t> indices();
42  MN_SYMBOL std::span<const uint32_t> indices() const;
43 
44  MN_SYMBOL std::size_t allocated() const;
45 
46  std::shared_ptr<TypeBuffer<Vertex>> vertex;
47  std::shared_ptr<TypeBuffer<uint32_t>> index;
48  };
49 }
Definition: Mesh.hpp:24
Definition: Mesh.hpp:17
Definition: Mesh.hpp:13
Definition: RenderFrame.hpp:25
Definition: Vector.hpp:12