X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmodel.hpp;h=096e1cfd3aff2738f6288a6909c557d227ed3909;hb=76b3ec0f6aa0dacf6d4944a2787991f3585299e8;hp=d5c77d174929756f2ace1445e887946b017dfe20;hpb=f932e8c0273794bcd954c9f5b504bad6140f7cf4;p=blank.git diff --git a/src/model.hpp b/src/model.hpp index d5c77d1..096e1cf 100644 --- a/src/model.hpp +++ b/src/model.hpp @@ -29,7 +29,7 @@ public: Normals normals; Indices indices; - void Clear() { + void Clear() noexcept { vertices.clear(); colors.clear(); normals.clear(); @@ -46,18 +46,18 @@ public: }; public: - Model(); - ~Model(); + Model() noexcept; + ~Model() noexcept; Model(const Model &) = delete; Model &operator =(const Model &) = delete; - Model(Model &&); - Model &operator =(Model &&); + Model(Model &&) noexcept; + Model &operator =(Model &&) noexcept; - void Update(const Buffer &); + void Update(const Buffer &) noexcept; - void Draw() const; + void Draw() const noexcept; private: enum Attribute { @@ -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() 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 Model &) = 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; + +}; + + class OutlineModel { public: @@ -92,21 +159,21 @@ public: Indices indices; public: - OutlineModel(); - ~OutlineModel(); + OutlineModel() noexcept; + ~OutlineModel() noexcept; OutlineModel(const OutlineModel &) = delete; OutlineModel &operator =(const OutlineModel &) = delete; - void Invalidate() { dirty = true; } + void Invalidate() noexcept { dirty = true; } - void Clear(); + void Clear() noexcept; void Reserve(int vtx_count, int idx_count); - void Draw(); + void Draw() noexcept; private: - void Update(); + void Update() noexcept; private: enum Attribute {