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