]> git.tdb.fi Git - libs/gl.git/blob - source/uniformblock.h
Use bezier splines in Animation
[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 #include "vector.h"
9
10 namespace Msp {
11 namespace GL {
12
13 class BufferRange;
14 class Matrix;
15 class Uniform;
16 struct Color;
17
18 /**
19 Stores uniforms with a specific layout.  Both named and default uniform blocks
20 are supported.
21 */
22 class UniformBlock: public Bufferable
23 {
24 private:
25         std::map<int, const Uniform *> uniforms;
26         unsigned size;
27         std::vector<char> data;
28         mutable BufferRange *buf_range;
29
30         UniformBlock(const UniformBlock &);
31         UniformBlock &operator=(const UniformBlock &);
32 public:
33         UniformBlock();
34         UniformBlock(unsigned);
35         ~UniformBlock();
36
37 private:
38         virtual unsigned get_data_size() const { return size; }
39         virtual const void *get_data_pointer() const { return &data[0]; }
40         virtual unsigned get_alignment() const;
41         virtual void offset_changed();
42         virtual void upload_data(char *) 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