]> git.tdb.fi Git - libs/gl.git/blob - source/vertexsetup.h
Add functions for setting arrays of 2x2 and 3x3 matrix uniforms
[libs/gl.git] / source / vertexsetup.h
1 #ifndef MSP_GL_VERTEXSETUP_H_
2 #define MSP_GL_VERTEXSETUP_H_
3
4 #include "bindable.h"
5
6 namespace Msp {
7 namespace GL {
8
9 class VertexArray;
10
11 /**
12 Combines a VertexArray with an index buffer.  This wraps OpenGL's vertex array
13 objects.  Intended for internal use.
14 */
15 class VertexSetup: public Bindable<VertexSetup>
16 {
17 private:
18         enum ComponentMask
19         {
20                 VERTEX_ARRAY = 1,
21                 INSTANCE_ARRAY = 2,
22                 INDEX_BUFFER = 4
23         };
24
25         unsigned id;
26         mutable unsigned dirty;
27         const VertexArray *vertex_array;
28         const VertexArray *inst_array;
29         const Buffer *index_buffer;
30
31 public:
32         VertexSetup();
33         ~VertexSetup();
34
35         void set_vertex_array(const VertexArray &);
36         void set_instance_array(const VertexArray *);
37         void set_index_buffer(const Buffer &);
38         const VertexArray *get_vertex_array() const { return vertex_array; }
39         const VertexArray *get_instance_array() const { return inst_array; }
40         const Buffer *get_index_buffer() const { return index_buffer; }
41
42 private:
43         void update(unsigned) const;
44         void update_vertex_array(const VertexArray &, unsigned, unsigned, bool) const;
45
46 public:
47         void bind() const;
48         static void unbind();
49 };
50
51 } // namespace GL
52 } // namespace Msp
53
54 #endif