X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmodel.hpp;h=ea9bf119e80e6061084117edb0e1c11549a8b1a0;hb=2d5671c2ef977defae9ce0ce7248582ab3e8f011;hp=02ab3f274bd5b096205f9c1d4a153bff004e7c4a;hpb=3baab6cca7423d55ea08288d96570b02380b1fe9;p=blank.git diff --git a/src/model.hpp b/src/model.hpp index 02ab3f2..ea9bf11 100644 --- a/src/model.hpp +++ b/src/model.hpp @@ -11,27 +11,89 @@ namespace blank { class Model { public: + using Index = unsigned int; + +public: + std::vector vertices; + std::vector colors; + std::vector normals; + std::vector indices; + +public: + Model(); + ~Model(); + + Model(const Model &) = delete; + Model &operator =(const Model &) = delete; + + Model(Model &&); + Model &operator =(Model &&); + + void Invalidate() { dirty = true; } + + void Clear(); + void Reserve(int vtx_count, int idx_count); + + void CheckUpdate(); + void Draw(); + +private: + void Update(); + +private: enum Attribute { ATTRIB_VERTEX, ATTRIB_COLOR, ATTRIB_NORMAL, + ATTRIB_INDEX, ATTRIB_COUNT, }; + GLuint va; + GLuint handle[ATTRIB_COUNT]; + bool dirty; + +}; + + +class OutlineModel { + public: - explicit Model( - std::vector &&vertices, - std::vector &&colors, - std::vector &&normals); - ~Model(); + using Index = unsigned short; + +public: + std::vector vertices; + std::vector colors; + std::vector indices; + +public: + OutlineModel(); + ~OutlineModel(); + + OutlineModel(const OutlineModel &) = delete; + OutlineModel &operator =(const OutlineModel &) = delete; + + void Invalidate() { dirty = true; } + + void Clear(); + void Reserve(int vtx_count, int idx_count); void Draw(); private: - std::vector vertices; - std::vector colors; - std::vector normals; + void Update(); + +private: + enum Attribute { + ATTRIB_VERTEX, + ATTRIB_COLOR, + ATTRIB_INDEX, + ATTRIB_COUNT, + }; + + GLuint va; GLuint handle[ATTRIB_COUNT]; + bool dirty; };