]> git.tdb.fi Git - libs/gl.git/blob - source/uniformblock.h
Construct uniform buffers for named uniform blocks
[libs/gl.git] / source / uniformblock.h
1 #ifndef MSP_GL_UNIFORMBLOCK_H_
2 #define MSP_GL_UNIFORMBLOCK_H_
3
4 #include <map>
5 #include <vector>
6 #include "bufferable.h"
7 #include "program.h"
8
9 namespace Msp {
10 namespace GL {
11
12 class BufferRange;
13 class Color;
14 class Matrix;
15 class Uniform;
16 class Vector3;
17 class Vector4;
18
19 class UniformBlock: public Bufferable
20 {
21 private:
22         std::map<int, const Uniform *> uniforms;
23         unsigned size;
24         std::vector<char> data;
25         mutable BufferRange *buf_range;
26
27         UniformBlock(const UniformBlock &);
28         UniformBlock &operator=(const UniformBlock &);
29 public:
30         UniformBlock();
31         UniformBlock(unsigned);
32
33 private:
34         virtual const void *get_data() const { return &data[0]; }
35         virtual unsigned get_data_size() const { return size; }
36
37 public:
38         void attach(int, const Uniform &);
39         void attach(const Program::UniformInfo &, const Uniform &);
40
41         void apply(int) const;
42 };
43
44 } // namespace GL
45 } // namespace Msp
46
47 #endif