]> git.localhorst.tv Git - blank.git/blob - src/graphics/SkyBoxMesh.hpp
glm backwards compatibility
[blank.git] / src / graphics / SkyBoxMesh.hpp
1 #ifndef BLANK_GRAPHICS_SKYBOXMESH_HPP_
2 #define BLANK_GRAPHICS_SKYBOXMESH_HPP_
3
4 #include "glm.hpp"
5 #include "VertexArray.hpp"
6
7 #include <vector>
8
9
10 namespace blank {
11
12 class SkyBoxMesh {
13
14 public:
15         using Position = glm::vec3;
16         using Index = unsigned int;
17
18         using Positions = std::vector<Position>;
19         using Indices = std::vector<Index>;
20
21         enum Attribute {
22                 ATTRIB_VERTEX,
23                 ATTRIB_INDEX,
24                 ATTRIB_COUNT,
25         };
26
27         struct Buffer {
28
29                 Positions vertices;
30                 Indices indices;
31
32                 void Clear() noexcept {
33                         vertices.clear();
34                         indices.clear();
35                 }
36
37                 void Reserve(size_t p, size_t i) {
38                         vertices.reserve(p);
39                         indices.reserve(i);
40                 }
41
42         };
43
44         using VAO = VertexArray<ATTRIB_COUNT>;
45
46 public:
47         void LoadUnitBox();
48         void Update(const Buffer &) noexcept;
49
50         bool Empty() const noexcept {
51                 return vao.Empty();
52         }
53
54         void Draw() const noexcept {
55                 vao.DrawTriangleElements();
56         }
57
58 private:
59         VAO vao;
60
61 };
62
63 }
64
65 #endif