X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmodel%2FModel.hpp;fp=src%2Fmodel%2FModel.hpp;h=95ad086402a6c58838012b0c9102350538cb9499;hb=b7d09e1e35ef90282c97509e0020b20db3c7ea9f;hp=0000000000000000000000000000000000000000;hpb=e53a0e2e711a7d8bd9b0ddacd1360aa14370643f;p=blank.git diff --git a/src/model/Model.hpp b/src/model/Model.hpp new file mode 100644 index 0000000..95ad086 --- /dev/null +++ b/src/model/Model.hpp @@ -0,0 +1,79 @@ +#ifndef BLANK_MODEL_MODEL_HPP_ +#define BLANK_MODEL_MODEL_HPP_ + +#include +#include +#include + + +namespace blank { + +class Model { + +public: + using Position = glm::vec3; + using Color = glm::vec3; + using Normal = glm::vec3; + using Index = unsigned int; + + using Positions = std::vector; + using Colors = std::vector; + using Normals = std::vector; + using Indices = std::vector; + +public: + struct Buffer { + + Positions vertices; + Colors colors; + Normals normals; + Indices indices; + + void Clear() noexcept { + vertices.clear(); + colors.clear(); + normals.clear(); + indices.clear(); + } + + void Reserve(size_t p, size_t i) { + vertices.reserve(p); + colors.reserve(p); + normals.reserve(p); + indices.reserve(i); + } + + }; + +public: + Model() noexcept; + ~Model() noexcept; + + Model(const Model &) = delete; + Model &operator =(const Model &) = delete; + + Model(Model &&) noexcept; + Model &operator =(Model &&) noexcept; + + void Update(const Buffer &) noexcept; + + void Draw() const noexcept; + +private: + enum Attribute { + ATTRIB_VERTEX, + ATTRIB_COLOR, + ATTRIB_NORMAL, + ATTRIB_INDEX, + ATTRIB_COUNT, + }; + + GLuint va; + GLuint handle[ATTRIB_COUNT]; + size_t count; + +}; + +} + +#endif