3 This file is part of libmspgl
4 Copyright © 2007-2010 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #ifndef MSP_GL_VERTEXARRAY_H_
9 #define MSP_GL_VERTEXARRAY_H_
13 #include <msp/core/refptr.h>
14 #include <msp/datafile/loader.h>
16 #include "primitivetype.h"
17 #include "vertexarraybuilder.h"
18 #include "vertexformat.h"
28 class Loader: public DataFile::Loader, public VertexArrayBuilder
31 Loader(VertexArray &);
39 B = (sizeof(unsigned)*CHAR_BIT),
48 bool is_set(unsigned) const;
52 std::vector<float> data;
58 static ArrayMask enabled_arrays;
60 VertexArray(const VertexArray &);
61 VertexArray &operator=(const VertexArray &);
63 VertexArray(const VertexFormat &);
66 const VertexFormat &get_format() const { return format; }
67 const std::vector<float> &get_data() const { return data; }
68 void use_vertex_buffer();
69 void use_vertex_buffer(Buffer *);
70 void reserve(unsigned);
71 unsigned size() const { return data.size()/stride; }
73 void reset(const VertexFormat &);
76 float *modify(unsigned);
77 const float *operator[](unsigned i) const { return &data[0]+i*stride; }
83 void array_element(int);
84 void draw_arrays(PrimitiveType, int, unsigned);
85 void draw_elements(PrimitiveType, unsigned, DataType, const void *);
86 void draw_range_elements(PrimitiveType, unsigned, unsigned, unsigned, DataType, const void *);
88 inline void draw_elements(PrimitiveType mode, unsigned count, const unsigned *indices)
89 { draw_elements(mode, count, UNSIGNED_INT, indices); }
91 inline void draw_elements(PrimitiveType mode, unsigned count, const unsigned short *indices)
92 { draw_elements(mode, count, UNSIGNED_SHORT, indices); }
94 inline void draw_range_elements(PrimitiveType mode, unsigned low, unsigned high, unsigned count, const unsigned short *indices)
95 { draw_range_elements(mode, low, high, count, UNSIGNED_SHORT, indices); }
97 inline void draw_range_elements(PrimitiveType mode, unsigned low, unsigned high, unsigned count, const unsigned *indices)
98 { draw_range_elements(mode, low, high, count, UNSIGNED_INT, indices); }