X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmodel.hpp;h=62f467c4f787a6de9547f450af12197dd3e955f6;hb=0d6efa28245acaf22383bdf398b5537d1fe33ce2;hp=4fd4515563022215e0ca8e2f847813b4610b501f;hpb=2d8c7c015478a4528c0909f11d43998b1393948d;p=blank.git diff --git a/src/model.hpp b/src/model.hpp index 4fd4515..62f467c 100644 --- a/src/model.hpp +++ b/src/model.hpp @@ -11,9 +11,21 @@ namespace blank { class Model { public: - std::vector vertices; - std::vector colors; - std::vector normals; + 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: + Positions vertices; + Colors colors; + Normals normals; + Indices indices; public: Model(); @@ -22,11 +34,15 @@ public: Model(const Model &) = delete; Model &operator =(const Model &) = delete; + Model(Model &&); + Model &operator =(Model &&); + void Invalidate() { dirty = true; } void Clear(); - void Reserve(int); + void Reserve(int vtx_count, int idx_count); + void CheckUpdate(); void Draw(); private: @@ -37,9 +53,11 @@ private: ATTRIB_VERTEX, ATTRIB_COLOR, ATTRIB_NORMAL, + ATTRIB_INDEX, ATTRIB_COUNT, }; + GLuint va; GLuint handle[ATTRIB_COUNT]; bool dirty; @@ -49,8 +67,18 @@ private: class OutlineModel { public: - std::vector vertices; - std::vector colors; + 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: + Positions vertices; + Colors colors; + Indices indices; public: OutlineModel(); @@ -62,7 +90,7 @@ public: void Invalidate() { dirty = true; } void Clear(); - void Reserve(int); + void Reserve(int vtx_count, int idx_count); void Draw(); @@ -73,9 +101,11 @@ private: enum Attribute { ATTRIB_VERTEX, ATTRIB_COLOR, + ATTRIB_INDEX, ATTRIB_COUNT, }; + GLuint va; GLuint handle[ATTRIB_COUNT]; bool dirty;