]> git.localhorst.tv Git - blank.git/blobdiff - src/model/BlockModel.hpp
split composite model in template and instance
[blank.git] / src / model / BlockModel.hpp
index d1a37c90f727cc29ac05a6de56bd815ea6781e28..2ffd816f913831f3fd46acdc86346e7b8ec811fe 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef BLANK_MODEL_BLOCKMODEL_HPP_
 #define BLANK_MODEL_BLOCKMODEL_HPP_
 
+#include "../graphics/VertexArray.hpp"
+
 #include <vector>
 #include <GL/glew.h>
 #include <glm/glm.hpp>
@@ -12,25 +14,37 @@ class BlockModel {
 
 public:
        using Position = glm::vec3;
+       using TexCoord = glm::vec3;
        using Color = glm::vec3;
        using Light = float;
        using Index = unsigned int;
 
        using Positions = std::vector<Position>;
+       using TexCoords = std::vector<TexCoord>;
        using Colors = std::vector<Color>;
        using Lights = std::vector<Light>;
        using Indices = std::vector<Index>;
 
-public:
+       enum Attribute {
+               ATTRIB_VERTEX,
+               ATTRIB_TEXCOORD,
+               ATTRIB_COLOR,
+               ATTRIB_LIGHT,
+               ATTRIB_INDEX,
+               ATTRIB_COUNT,
+       };
+
        struct Buffer {
 
                Positions vertices;
+               TexCoords tex_coords;
                Colors colors;
                Lights lights;
                Indices indices;
 
                void Clear() noexcept {
                        vertices.clear();
+                       tex_coords.clear();
                        colors.clear();
                        lights.clear();
                        indices.clear();
@@ -38,6 +52,7 @@ public:
 
                void Reserve(size_t p, size_t i) {
                        vertices.reserve(p);
+                       tex_coords.reserve(p);
                        colors.reserve(p);
                        lights.reserve(p);
                        indices.reserve(i);
@@ -45,32 +60,15 @@ public:
 
        };
 
-public:
-       BlockModel() noexcept;
-       ~BlockModel() noexcept;
-
-       BlockModel(const BlockModel &) = delete;
-       BlockModel &operator =(const BlockModel &) = delete;
-
-       BlockModel(BlockModel &&) noexcept;
-       BlockModel &operator =(BlockModel &&) noexcept;
+       using VAO = VertexArray<ATTRIB_COUNT>;
 
+public:
        void Update(const Buffer &) noexcept;
 
        void Draw() const noexcept;
 
 private:
-       enum Attribute {
-               ATTRIB_VERTEX,
-               ATTRIB_COLOR,
-               ATTRIB_LIGHT,
-               ATTRIB_INDEX,
-               ATTRIB_COUNT,
-       };
-
-       GLuint va;
-       GLuint handle[ATTRIB_COUNT];
-       size_t count;
+       VAO vao;
 
 };