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 static bool legacy_used;
46 VertexArray(const VertexArray &);
47 VertexArray &operator=(const VertexArray &);
49 VertexArray(const VertexFormat &);
52 void reset(const VertexFormat &);
53 const VertexFormat &get_format() const { return format; }
55 static unsigned get_array_slot(unsigned char);
58 /// Deprecated alias for use_buffer
59 void use_vertex_buffer(Buffer *b) { use_buffer(b); }
62 void reserve(unsigned);
64 float *modify(unsigned);
66 virtual unsigned get_data_size() const;
67 virtual const void *get_data_pointer() const { return &data[0]; }
70 unsigned size() const { return data.size()/stride; }
71 const std::vector<float> &get_data() const { return data; }
72 const float *operator[](unsigned i) const { return &data[0]+i*stride; }
74 void bind() const { apply(); }
75 void apply(bool = true) const;
77 static void apply_arrays(const std::vector<Array> *, const std::vector<Array> *, const float *, unsigned, bool);