]> git.tdb.fi Git - libs/gl.git/blob - source/uniformblock.h
Lots of comment updates
[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 /**
20 Stores uniforms with a specific layout.  Both named and default uniform blocks
21 are supported.
22 */
23 class UniformBlock: public Bufferable
24 {
25 private:
26         std::map<int, const Uniform *> uniforms;
27         unsigned size;
28         std::vector<char> data;
29         mutable BufferRange *buf_range;
30
31         UniformBlock(const UniformBlock &);
32         UniformBlock &operator=(const UniformBlock &);
33 public:
34         UniformBlock();
35         UniformBlock(unsigned);
36         ~UniformBlock();
37
38 private:
39         virtual unsigned get_data_size() const { return size; }
40         virtual unsigned get_alignment() const;
41         virtual void offset_changed();
42         virtual void upload_data() const;
43
44 public:
45         void attach(int, const Uniform &);
46         void attach(const Program::UniformInfo &, const Uniform &);
47
48         void apply(int) const;
49 };
50
51 } // namespace GL
52 } // namespace Msp
53
54 #endif