X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmodel%2FBlockModel.hpp;fp=src%2Fmodel%2FBlockModel.hpp;h=d1a37c90f727cc29ac05a6de56bd815ea6781e28;hb=b7d09e1e35ef90282c97509e0020b20db3c7ea9f;hp=0000000000000000000000000000000000000000;hpb=e53a0e2e711a7d8bd9b0ddacd1360aa14370643f;p=blank.git diff --git a/src/model/BlockModel.hpp b/src/model/BlockModel.hpp new file mode 100644 index 0000000..d1a37c9 --- /dev/null +++ b/src/model/BlockModel.hpp @@ -0,0 +1,79 @@ +#ifndef BLANK_MODEL_BLOCKMODEL_HPP_ +#define BLANK_MODEL_BLOCKMODEL_HPP_ + +#include +#include +#include + + +namespace blank { + +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() noexcept { + 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() noexcept; + ~BlockModel() noexcept; + + BlockModel(const BlockModel &) = delete; + BlockModel &operator =(const BlockModel &) = delete; + + BlockModel(BlockModel &&) noexcept; + BlockModel &operator =(BlockModel &&) noexcept; + + 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; + +}; + +} + +#endif