]> git.localhorst.tv Git - blank.git/blob - src/model/BlockModel.hpp
implemented font redering
[blank.git] / src / model / BlockModel.hpp
1 #ifndef BLANK_MODEL_BLOCKMODEL_HPP_
2 #define BLANK_MODEL_BLOCKMODEL_HPP_
3
4 #include <vector>
5 #include <GL/glew.h>
6 #include <glm/glm.hpp>
7
8
9 namespace blank {
10
11 class BlockModel {
12
13 public:
14         using Position = glm::vec3;
15         using Color = glm::vec3;
16         using Light = float;
17         using Index = unsigned int;
18
19         using Positions = std::vector<Position>;
20         using Colors = std::vector<Color>;
21         using Lights = std::vector<Light>;
22         using Indices = std::vector<Index>;
23
24 public:
25         struct Buffer {
26
27                 Positions vertices;
28                 Colors colors;
29                 Lights lights;
30                 Indices indices;
31
32                 void Clear() noexcept {
33                         vertices.clear();
34                         colors.clear();
35                         lights.clear();
36                         indices.clear();
37                 }
38
39                 void Reserve(size_t p, size_t i) {
40                         vertices.reserve(p);
41                         colors.reserve(p);
42                         lights.reserve(p);
43                         indices.reserve(i);
44                 }
45
46         };
47
48 public:
49         BlockModel() noexcept;
50         ~BlockModel() noexcept;
51
52         BlockModel(const BlockModel &) = delete;
53         BlockModel &operator =(const BlockModel &) = delete;
54
55         BlockModel(BlockModel &&) noexcept;
56         BlockModel &operator =(BlockModel &&) noexcept;
57
58         void Update(const Buffer &) noexcept;
59
60         void Draw() const noexcept;
61
62 private:
63         enum Attribute {
64                 ATTRIB_VERTEX,
65                 ATTRIB_COLOR,
66                 ATTRIB_LIGHT,
67                 ATTRIB_INDEX,
68                 ATTRIB_COUNT,
69         };
70
71         GLuint va;
72         GLuint handle[ATTRIB_COUNT];
73         size_t count;
74
75 };
76
77 }
78
79 #endif