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;
43 VertexArray(const VertexArray &);
44 VertexArray &operator=(const VertexArray &);
46 VertexArray(const VertexFormat &);
49 void reset(const VertexFormat &);
50 const VertexFormat &get_format() const { return format; }
52 static unsigned get_array_slot(unsigned char);
55 /// Deprecated alias for use_buffer
56 void use_vertex_buffer(Buffer *b) { use_buffer(b); }
59 void reserve(unsigned);
61 float *modify(unsigned);
63 virtual unsigned get_data_size() const;
64 virtual void upload_data() const;
67 unsigned size() const { return data.size()/stride; }
68 const std::vector<float> &get_data() const { return data; }
69 const float *operator[](unsigned i) const { return &data[0]+i*stride; }
73 static void apply_arrays(const std::vector<Array> *, const std::vector<Array> *, const float *, unsigned);