]> git.tdb.fi Git - libs/gl.git/blob - source/vertexarray.h
Make the use of DevIL optional
[libs/gl.git] / source / vertexarray.h
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2007  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GL_VERTEXARRAY_H_
9 #define MSP_GL_VERTEXARRAY_H_
10
11 #include <vector>
12 #include <msp/core/refptr.h>
13 #include <msp/datafile/loader.h>
14 #include "primitivetype.h"
15 #include "types.h"
16 #include "vertexarraybuilder.h"
17 #include "vertexformat.h"
18
19 namespace Msp {
20 namespace GL {
21
22 class VertexBuffer;
23
24 class VertexArray
25 {
26 public:
27         class Loader: public DataFile::Loader, public VertexArrayBuilder
28         {
29         public:
30                 Loader(VertexArray &);
31         };
32
33         VertexArray(VertexFormat);
34         ~VertexArray();
35
36         VertexFormat get_format() const { return format; }
37         const std::vector<float> &get_data() const { return data; }
38         void         use_vertex_buffer();
39         void         use_vertex_buffer(VertexBuffer *);
40         void         reserve(unsigned);
41         unsigned     size() const { return data.size()/stride; }
42         void         clear();
43         void         reset(VertexFormat);
44         RefPtr<VertexArrayBuilder> modify();
45         void         apply() const;
46         void         update_data();
47 private:
48         VertexFormat format;
49         std::vector<float> data;
50         uint         stride;
51         VertexBuffer *vbuf;
52         bool         own_vbuf;
53
54         VertexArray(const VertexArray &);
55         VertexArray &operator=(const VertexArray &);
56         void set_array(unsigned, unsigned, unsigned) const;
57
58         static unsigned enabled_arrays;
59 };
60
61 } // namespace GL
62 } // namespace Msp
63
64 #endif