X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmodel.hpp;h=62f467c4f787a6de9547f450af12197dd3e955f6;hb=0d6efa28245acaf22383bdf398b5537d1fe33ce2;hp=c0bda4112fe052231340dbcd3a30ce7857e4c3df;hpb=d18be10ef3f0a7b61c6f5c4c4096ca2b776c75b3;p=blank.git diff --git a/src/model.hpp b/src/model.hpp index c0bda41..62f467c 100644 --- a/src/model.hpp +++ b/src/model.hpp @@ -1,6 +1,8 @@ #ifndef BLANK_MODEL_HPP_ #define BLANK_MODEL_HPP_ +#include +#include #include @@ -8,25 +10,104 @@ 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: + Positions vertices; + Colors colors; + Normals normals; + Indices indices; + public: Model(); ~Model(); - glm::mat4 Transform() const; + 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: + using Position = glm::vec3; + using Color = glm::vec3; + using Index = unsigned short; + + using Positions = std::vector; + using Colors = std::vector; + using Indices = std::vector; - void Position(glm::vec3 pos) { position = pos; } - void Move(glm::vec3 delta) { position += delta; } +public: + Positions vertices; + Colors colors; + Indices indices; - // all angles in radians (full circle = 2π) - void Pitch(float p) { pitch = p; } - void RotatePitch(float delta) { pitch += delta; } - void Yaw(float y) { yaw = y; } - void RotateYaw(float delta) { yaw += delta; } +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: - glm::vec3 position; - float pitch; - float yaw; + void Update(); + +private: + enum Attribute { + ATTRIB_VERTEX, + ATTRIB_COLOR, + ATTRIB_INDEX, + ATTRIB_COUNT, + }; + + GLuint va; + GLuint handle[ATTRIB_COUNT]; + bool dirty; };