X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmodel.hpp;h=d5c77d174929756f2ace1445e887946b017dfe20;hb=c877ddd21f402381d88a6bebdd5c7c0b4ac28ba9;hp=62f467c4f787a6de9547f450af12197dd3e955f6;hpb=0d6efa28245acaf22383bdf398b5537d1fe33ce2;p=blank.git diff --git a/src/model.hpp b/src/model.hpp index 62f467c..d5c77d1 100644 --- a/src/model.hpp +++ b/src/model.hpp @@ -22,10 +22,28 @@ public: using Indices = std::vector; public: - Positions vertices; - Colors colors; - Normals normals; - Indices 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(); @@ -37,16 +55,9 @@ public: Model(Model &&); Model &operator =(Model &&); - void Invalidate() { dirty = true; } - - void Clear(); - void Reserve(int vtx_count, int idx_count); + void Update(const Buffer &); - void CheckUpdate(); - void Draw(); - -private: - void Update(); + void Draw() const; private: enum Attribute { @@ -59,7 +70,7 @@ private: GLuint va; GLuint handle[ATTRIB_COUNT]; - bool dirty; + size_t count; };