]> git.localhorst.tv Git - blank.git/blobdiff - src/model/OutlineModel.hpp
"streamlined" model/VAO handling
[blank.git] / src / model / OutlineModel.hpp
index 308ab5195c68a07a638d9caaeec0dd2b0a735f73..ba85fc8e57243b9418765c9fd0125f2a2a93f7f5 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef BLANK_MODEL_OUTLINEMODEL_HPP_
 #define BLANK_MODEL_OUTLINEMODEL_HPP_
 
+#include "../graphics/VertexArray.hpp"
+
 #include <vector>
 #include <GL/glew.h>
 #include <glm/glm.hpp>
@@ -19,39 +21,42 @@ public:
        using Colors = std::vector<Color>;
        using Indices = std::vector<Index>;
 
-public:
-       Positions vertices;
-       Colors colors;
-       Indices indices;
+       enum Attribute {
+               ATTRIB_VERTEX,
+               ATTRIB_COLOR,
+               ATTRIB_INDEX,
+               ATTRIB_COUNT,
+       };
 
-public:
-       OutlineModel() noexcept;
-       ~OutlineModel() noexcept;
+       struct Buffer {
 
-       OutlineModel(const OutlineModel &) = delete;
-       OutlineModel &operator =(const OutlineModel &) = delete;
+               Positions vertices;
+               Colors colors;
+               Indices indices;
 
-       void Invalidate() noexcept { dirty = true; }
+               void Clear() noexcept {
+                       vertices.clear();
+                       colors.clear();
+                       indices.clear();
+               }
 
-       void Clear() noexcept;
-       void Reserve(int vtx_count, int idx_count);
+               void Reserve(size_t p, size_t i) {
+                       vertices.reserve(p);
+                       colors.reserve(p);
+                       indices.reserve(i);
+               }
 
-       void Draw() noexcept;
+       };
 
-private:
-       void Update() noexcept;
+       using VAO = VertexArray<ATTRIB_COUNT>;
 
-private:
-       enum Attribute {
-               ATTRIB_VERTEX,
-               ATTRIB_COLOR,
-               ATTRIB_INDEX,
-               ATTRIB_COUNT,
-       };
+public:
+       void Update(const Buffer &) noexcept;
 
-       GLuint va;
-       GLuint handle[ATTRIB_COUNT];
-       bool dirty;
+       void Draw() noexcept;
+
+private:
+       VAO vao;
 
 };