X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmodel.hpp;h=557b4acc6ebe4cb1092a95361cb10d14709703c3;hb=4ef32c5a4a5bdb6da8383f66d8265715eb2ed4f9;hp=d5c77d174929756f2ace1445e887946b017dfe20;hpb=f932e8c0273794bcd954c9f5b504bad6140f7cf4;p=blank.git diff --git a/src/model.hpp b/src/model.hpp index d5c77d1..557b4ac 100644 --- a/src/model.hpp +++ b/src/model.hpp @@ -75,6 +75,73 @@ private: }; +class BlockModel { + +public: + using Position = glm::vec3; + using Color = glm::vec3; + using Light = float; + using Index = unsigned int; + + using Positions = std::vector; + using Colors = std::vector; + using Lights = std::vector; + using Indices = std::vector; + +public: + struct Buffer { + + Positions vertices; + Colors colors; + Lights lights; + Indices indices; + + void Clear() { + vertices.clear(); + colors.clear(); + lights.clear(); + indices.clear(); + } + + void Reserve(size_t p, size_t i) { + vertices.reserve(p); + colors.reserve(p); + lights.reserve(p); + indices.reserve(i); + } + + }; + +public: + BlockModel(); + ~BlockModel(); + + BlockModel(const BlockModel &) = delete; + BlockModel &operator =(const Model &) = delete; + + BlockModel(BlockModel &&); + BlockModel &operator =(BlockModel &&); + + void Update(const Buffer &); + + void Draw() const; + +private: + enum Attribute { + ATTRIB_VERTEX, + ATTRIB_COLOR, + ATTRIB_LIGHT, + ATTRIB_INDEX, + ATTRIB_COUNT, + }; + + GLuint va; + GLuint handle[ATTRIB_COUNT]; + size_t count; + +}; + + class OutlineModel { public: