]> git.tdb.fi Git - libs/gl.git/blob - source/uniformblock.h
Alter the working logic of Bufferable to avoid some problems
[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 void offset_changed();
37         virtual void upload_data() const;
38
39 public:
40         void attach(int, const Uniform &);
41         void attach(const Program::UniformInfo &, const Uniform &);
42
43         void apply(int) const;
44 };
45
46 } // namespace GL
47 } // namespace Msp
48
49 #endif