X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmodel.hpp;h=d5c77d174929756f2ace1445e887946b017dfe20;hb=3072e2cd49ad1614100d1a1c73afe6a4888fb875;hp=6e9583b3ec84f6ae05c7f1beaeeaa05b7e36e75b;hpb=82426ae2997d2b21703d2d5afb631a84736e975f;p=blank.git diff --git a/src/model.hpp b/src/model.hpp index 6e9583b..d5c77d1 100644 --- a/src/model.hpp +++ b/src/model.hpp @@ -11,13 +11,39 @@ 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: - std::vector vertices; - std::vector colors; - std::vector normals; - std::vector indices; + struct Buffer { + + Positions vertices; + Colors colors; + Normals normals; + Indices indices; + + void Clear() { + 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(); @@ -29,15 +55,9 @@ public: Model(Model &&); Model &operator =(Model &&); - void Invalidate() { dirty = true; } + void Update(const Buffer &); - void Clear(); - void Reserve(int vtx_count, int idx_count); - - void Draw(); - -private: - void Update(); + void Draw() const; private: enum Attribute { @@ -48,8 +68,9 @@ private: ATTRIB_COUNT, }; + GLuint va; GLuint handle[ATTRIB_COUNT]; - bool dirty; + size_t count; }; @@ -57,12 +78,18 @@ private: class OutlineModel { public: + using Position = glm::vec3; + using Color = glm::vec3; using Index = unsigned short; + using Positions = std::vector; + using Colors = std::vector; + using Indices = std::vector; + public: - std::vector vertices; - std::vector colors; - std::vector indices; + Positions vertices; + Colors colors; + Indices indices; public: OutlineModel(); @@ -89,6 +116,7 @@ private: ATTRIB_COUNT, }; + GLuint va; GLuint handle[ATTRIB_COUNT]; bool dirty;