]> git.localhorst.tv Git - blank.git/blob - src/model/EntityModel.hpp
cube map textures
[blank.git] / src / model / EntityModel.hpp
1 #ifndef BLANK_MODEL_ENTITYMODEL_HPP_
2 #define BLANK_MODEL_ENTITYMODEL_HPP_
3
4 #include "../graphics/VertexArray.hpp"
5
6 #include <vector>
7 #include <GL/glew.h>
8 #include <glm/glm.hpp>
9
10
11 namespace blank {
12
13 class EntityModel {
14
15 public:
16         using Position = glm::vec3;
17         using TexCoord = glm::vec3;
18         using Color = 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 Colors = std::vector<Color>;
25         using Normals = std::vector<Normal>;
26         using Indices = std::vector<Index>;
27
28         enum Attribute {
29                 ATTRIB_VERTEX,
30                 ATTRIB_TEXCOORD,
31                 ATTRIB_COLOR,
32                 ATTRIB_NORMAL,
33                 ATTRIB_INDEX,
34                 ATTRIB_COUNT,
35         };
36
37         struct Buffer {
38
39                 Positions vertices;
40                 TexCoords tex_coords;
41                 Colors colors;
42                 Normals normals;
43                 Indices indices;
44
45                 void Clear() noexcept {
46                         vertices.clear();
47                         tex_coords.clear();
48                         colors.clear();
49                         normals.clear();
50                         indices.clear();
51                 }
52
53                 void Reserve(size_t p, size_t i) {
54                         vertices.reserve(p);
55                         tex_coords.reserve(p);
56                         colors.reserve(p);
57                         normals.reserve(p);
58                         indices.reserve(i);
59                 }
60
61         };
62
63         using VAO = VertexArray<ATTRIB_COUNT>;
64
65 public:
66         void Update(const Buffer &) noexcept;
67
68         void Draw() const noexcept;
69
70 private:
71         VAO vao;
72
73 };
74
75 }
76
77 #endif