]> git.tdb.fi Git - libs/gl.git/blob - source/vertexarray.h
Move VertexFormat and VertexArrayBuilder to their own files
[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 "types.h"
15 #include "vertexarraybuilder.h"
16 #include "vertexformat.h"
17
18 namespace Msp {
19 namespace GL {
20
21 class VertexBuffer;
22
23 class VertexArray
24 {
25 public:
26         class Loader: public DataFile::Loader, public VertexArrayBuilder
27         {
28         public:
29                 Loader(VertexArray &);
30         };
31
32         VertexArray(VertexFormat);
33         ~VertexArray();
34
35         VertexFormat get_format() const { return format; }
36         const std::vector<float> &get_data() const { return data; }
37         void         use_vertex_buffer();
38         void         use_vertex_buffer(VertexBuffer *);
39         void         clear();
40         void         reset(VertexFormat);
41         RefPtr<VertexArrayBuilder> modify();
42         void         apply() const;
43         void         update_data();
44 private:
45         VertexFormat format;
46         std::vector<float> data;
47         uint         stride;
48         VertexBuffer *vbuf;
49         bool         own_vbuf;
50
51         VertexArray(const VertexArray &);
52         VertexArray &operator=(const VertexArray &);
53         void set_array(unsigned, unsigned, unsigned) const;
54
55         static unsigned enabled_arrays;
56 };
57
58 } // namespace GL
59 } // namespace Msp
60
61 #endif