1 #ifndef MSP_GL_VERTEXARRAY_H_
2 #define MSP_GL_VERTEXARRAY_H_
6 #include <msp/core/refptr.h>
7 #include <msp/datafile/loader.h>
10 #include "primitivetype.h"
11 #include "vertexarraybuilder.h"
12 #include "vertexformat.h"
19 class VertexArray: public Bindable<VertexArray>
22 class Loader: public DataFile::Loader, public VertexArrayBuilder
25 Loader(VertexArray &);
31 unsigned char component;
38 std::vector<float> data;
40 std::vector<Array> arrays;
45 VertexArray(const VertexArray &);
46 VertexArray &operator=(const VertexArray &);
48 VertexArray(const VertexFormat &);
51 void reset(const VertexFormat &);
52 const VertexFormat &get_format() const { return format; }
54 static unsigned get_array_slot(unsigned char);
57 void use_vertex_buffer();
58 void use_vertex_buffer(Buffer *);
61 void reserve(unsigned);
63 float *modify(unsigned);
68 unsigned size() const { return data.size()/stride; }
69 const std::vector<float> &get_data() const { return data; }
70 const float *operator[](unsigned i) const { return &data[0]+i*stride; }
74 static void apply_arrays(const std::vector<Array> *, const std::vector<Array> *, const float *, unsigned);