]> git.localhorst.tv Git - blank.git/blob - src/graphics/EntityMesh.hpp
use entity's eyes to aim
[blank.git] / src / graphics / EntityMesh.hpp
1 #ifndef BLANK_GRAPHICS_ENTITYMESH_HPP_
2 #define BLANK_GRAPHICS_ENTITYMESH_HPP_
3
4 #include "VertexArray.hpp"
5
6 #include <vector>
7 #include <GL/glew.h>
8 #include <glm/glm.hpp>
9
10
11 namespace blank {
12
13 class EntityMesh {
14
15 public:
16         using Position = glm::vec3;
17         using TexCoord = glm::vec3;
18         using ColorMod = glm::vec3;
19         using Normal = glm::vec3;
20         using Index = unsigned int;
21
22         using Positions = std::vector<Position>;
23         using TexCoords = std::vector<TexCoord>;
24         using ColorMods = std::vector<ColorMod>;
25         using Normals = std::vector<Normal>;
26         using Indices = std::vector<Index>;
27
28         enum Attribute {
29                 ATTRIB_VERTEX,
30                 ATTRIB_TEXCOORD,
31                 ATTRIB_HSL,
32                 ATTRIB_RGB,
33                 ATTRIB_NORMAL,
34                 ATTRIB_INDEX,
35                 ATTRIB_COUNT,
36         };
37
38         struct Buffer {
39
40                 Positions vertices;
41                 TexCoords tex_coords;
42                 ColorMods hsl_mods;
43                 ColorMods rgb_mods;
44                 Normals normals;
45                 Indices indices;
46
47                 void Clear() noexcept {
48                         vertices.clear();
49                         tex_coords.clear();
50                         hsl_mods.clear();
51                         rgb_mods.clear();
52                         normals.clear();
53                         indices.clear();
54                 }
55
56                 void Reserve(size_t p, size_t i) {
57                         vertices.reserve(p);
58                         tex_coords.reserve(p);
59                         hsl_mods.reserve(p);
60                         rgb_mods.reserve(p);
61                         normals.reserve(p);
62                         indices.reserve(i);
63                 }
64
65         };
66
67         using VAO = VertexArray<ATTRIB_COUNT>;
68
69 public:
70         void Update(const Buffer &) noexcept;
71
72         void Draw() const noexcept;
73
74 private:
75         VAO vao;
76
77 };
78
79 }
80
81 #endif