]> git.localhorst.tv Git - blank.git/blob - src/model/BlockModel.hpp
send entity visual from server to client
[blank.git] / src / model / BlockModel.hpp
1 #ifndef BLANK_MODEL_BLOCKMODEL_HPP_
2 #define BLANK_MODEL_BLOCKMODEL_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 BlockModel {
14
15 public:
16         using Position = glm::vec3;
17         using TexCoord = glm::vec3;
18         using Color = glm::vec3;
19         using Light = float;
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 Lights = std::vector<Light>;
26         using Indices = std::vector<Index>;
27
28         enum Attribute {
29                 ATTRIB_VERTEX,
30                 ATTRIB_TEXCOORD,
31                 ATTRIB_COLOR,
32                 ATTRIB_LIGHT,
33                 ATTRIB_INDEX,
34                 ATTRIB_COUNT,
35         };
36
37         struct Buffer {
38
39                 Positions vertices;
40                 TexCoords tex_coords;
41                 Colors colors;
42                 Lights lights;
43                 Indices indices;
44
45                 void Clear() noexcept {
46                         vertices.clear();
47                         tex_coords.clear();
48                         colors.clear();
49                         lights.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                         lights.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