]> git.localhorst.tv Git - blank.git/blob - src/model.hpp
increased convenience in build process
[blank.git] / src / model.hpp
1 #ifndef BLANK_MODEL_HPP_
2 #define BLANK_MODEL_HPP_
3
4 #include <vector>
5 #include <GL/glew.h>
6 #include <glm/glm.hpp>
7
8
9 namespace blank {
10
11 class Model {
12
13 public:
14         using Index = unsigned int;
15
16 public:
17         std::vector<glm::vec3> vertices;
18         std::vector<glm::vec3> colors;
19         std::vector<glm::vec3> normals;
20         std::vector<Index> indices;
21
22 public:
23         Model();
24         ~Model();
25
26         Model(const Model &) = delete;
27         Model &operator =(const Model &) = delete;
28
29         Model(Model &&);
30         Model &operator =(Model &&);
31
32         void Invalidate() { dirty = true; }
33
34         void Clear();
35         void Reserve(int vtx_count, int idx_count);
36
37         void CheckUpdate();
38         void Draw();
39
40 private:
41         void Update();
42
43 private:
44         enum Attribute {
45                 ATTRIB_VERTEX,
46                 ATTRIB_COLOR,
47                 ATTRIB_NORMAL,
48                 ATTRIB_INDEX,
49                 ATTRIB_COUNT,
50         };
51
52         GLuint va;
53         GLuint handle[ATTRIB_COUNT];
54         bool dirty;
55
56 };
57
58
59 class OutlineModel {
60
61 public:
62         using Index = unsigned short;
63
64 public:
65         std::vector<glm::vec3> vertices;
66         std::vector<glm::vec3> colors;
67         std::vector<Index> indices;
68
69 public:
70         OutlineModel();
71         ~OutlineModel();
72
73         OutlineModel(const OutlineModel &) = delete;
74         OutlineModel &operator =(const OutlineModel &) = delete;
75
76         void Invalidate() { dirty = true; }
77
78         void Clear();
79         void Reserve(int vtx_count, int idx_count);
80
81         void Draw();
82
83 private:
84         void Update();
85
86 private:
87         enum Attribute {
88                 ATTRIB_VERTEX,
89                 ATTRIB_COLOR,
90                 ATTRIB_INDEX,
91                 ATTRIB_COUNT,
92         };
93
94         GLuint va;
95         GLuint handle[ATTRIB_COUNT];
96         bool dirty;
97
98 };
99
100 }
101
102 #endif