class Model {
public:
+ using Position = glm::vec3;
+ using Color = glm::vec3;
+ using Normal = glm::vec3;
using Index = unsigned int;
+ using Positions = std::vector<Position>;
+ using Colors = std::vector<Color>;
+ using Normals = std::vector<Normal>;
+ using Indices = std::vector<Index>;
+
public:
- std::vector<glm::vec3> vertices;
- std::vector<glm::vec3> colors;
- std::vector<glm::vec3> normals;
- std::vector<Index> 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();
Model(Model &&);
Model &operator =(Model &&);
- void Invalidate() { dirty = true; }
+ void Update(const Buffer &);
- void Clear();
- void Reserve(int vtx_count, int idx_count);
-
- void Draw();
-
-private:
- void Update();
+ void Draw() const;
private:
enum Attribute {
ATTRIB_COUNT,
};
+ GLuint va;
GLuint handle[ATTRIB_COUNT];
- bool dirty;
+ size_t count;
};
class OutlineModel {
public:
+ using Position = glm::vec3;
+ using Color = glm::vec3;
using Index = unsigned short;
+ using Positions = std::vector<Position>;
+ using Colors = std::vector<Color>;
+ using Indices = std::vector<Index>;
+
public:
- std::vector<glm::vec3> vertices;
- std::vector<glm::vec3> colors;
- std::vector<Index> indices;
+ Positions vertices;
+ Colors colors;
+ Indices indices;
public:
OutlineModel();
ATTRIB_COUNT,
};
+ GLuint va;
GLuint handle[ATTRIB_COUNT];
bool dirty;