]> git.tdb.fi Git - libs/gl.git/blob - source/uniformblock.h
12b24de3d06a810aa16040b49d2df973e53eba5d
[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         ~UniformBlock();
33
34 private:
35         virtual unsigned get_data_size() const { return size; }
36         virtual unsigned get_alignment() const;
37         virtual void offset_changed();
38         virtual void upload_data() const;
39
40 public:
41         void attach(int, const Uniform &);
42         void attach(const Program::UniformInfo &, const Uniform &);
43
44         void apply(int) const;
45 };
46
47 } // namespace GL
48 } // namespace Msp
49
50 #endif