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 "primitivetype.h"
10 #include "vertexarraybuilder.h"
11 #include "vertexformat.h"
21 class Loader: public DataFile::Loader, public VertexArrayBuilder
24 Loader(VertexArray &);
32 B = (sizeof(unsigned)*CHAR_BIT),
41 bool is_set(unsigned) const;
45 std::vector<float> data;
51 static ArrayMask enabled_arrays;
53 VertexArray(const VertexArray &);
54 VertexArray &operator=(const VertexArray &);
56 VertexArray(const VertexFormat &);
59 const VertexFormat &get_format() const { return format; }
60 const std::vector<float> &get_data() const { return data; }
61 void use_vertex_buffer();
62 void use_vertex_buffer(Buffer *);
63 void reserve(unsigned);
64 unsigned size() const { return data.size()/stride; }
66 void reset(const VertexFormat &);
69 float *modify(unsigned);
70 const float *operator[](unsigned i) const { return &data[0]+i*stride; }
76 void array_element(int);
77 void draw_arrays(PrimitiveType, int, unsigned);
78 void draw_elements(PrimitiveType, unsigned, DataType, const void *);
79 void draw_range_elements(PrimitiveType, unsigned, unsigned, unsigned, DataType, const void *);
81 inline void draw_elements(PrimitiveType mode, unsigned count, const unsigned *indices)
82 { draw_elements(mode, count, UNSIGNED_INT, indices); }
84 inline void draw_elements(PrimitiveType mode, unsigned count, const unsigned short *indices)
85 { draw_elements(mode, count, UNSIGNED_SHORT, indices); }
87 inline void draw_range_elements(PrimitiveType mode, unsigned low, unsigned high, unsigned count, const unsigned short *indices)
88 { draw_range_elements(mode, low, high, count, UNSIGNED_SHORT, indices); }
90 inline void draw_range_elements(PrimitiveType mode, unsigned low, unsigned high, unsigned count, const unsigned *indices)
91 { draw_range_elements(mode, low, high, count, UNSIGNED_INT, indices); }