1 #ifndef MSP_GL_VERTEXARRAY_H_
2 #define MSP_GL_VERTEXARRAY_H_
6 #include <msp/core/refptr.h>
7 #include <msp/datafile/loader.h>
9 #include "bufferable.h"
11 #include "primitivetype.h"
12 #include "vertexarraybuilder.h"
13 #include "vertexformat.h"
20 class VertexArray: public Bindable<VertexArray>, public Bufferable
23 class Loader: public DataFile::Loader, public VertexArrayBuilder
26 Loader(VertexArray &);
32 unsigned char component;
39 std::vector<float> data;
41 std::vector<Array> arrays;
44 VertexArray(const VertexArray &);
45 VertexArray &operator=(const VertexArray &);
47 VertexArray(const VertexFormat &);
50 void reset(const VertexFormat &);
51 const VertexFormat &get_format() const { return format; }
53 static unsigned get_array_slot(unsigned char);
56 /// Deprecated alias for use_buffer
57 void use_vertex_buffer(Buffer *b) { use_buffer(b); }
60 void reserve(unsigned);
62 float *modify(unsigned);
64 virtual unsigned get_data_size() const;
65 virtual void upload_data() const;
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);