X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmodel.hpp;h=d5c77d174929756f2ace1445e887946b017dfe20;hb=3072e2cd49ad1614100d1a1c73afe6a4888fb875;hp=ea9bf119e80e6061084117edb0e1c11549a8b1a0;hpb=28fda9f7f55a9e806ade3f49f4e94f0242ec2c3c;p=blank.git diff --git a/src/model.hpp b/src/model.hpp index ea9bf11..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,16 +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 CheckUpdate(); - void Draw(); - -private: - void Update(); + void Draw() const; private: enum Attribute { @@ -51,7 +70,7 @@ private: GLuint va; GLuint handle[ATTRIB_COUNT]; - bool dirty; + size_t count; }; @@ -59,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();