]> git.tdb.fi Git - libs/gl.git/blob - source/core/uniformblock.h
Check the flat qualifier from the correct member
[libs/gl.git] / source / core / uniformblock.h
1 #ifndef MSP_GL_UNIFORMBLOCK_H_
2 #define MSP_GL_UNIFORMBLOCK_H_
3
4 #include <vector>
5 #include <msp/core/noncopyable.h>
6 #include "bufferable.h"
7 #include "reflectdata.h"
8 #include "uniformblock_backend.h"
9
10 namespace Msp {
11 namespace GL {
12
13 /**
14 Stores uniform values in a block of memory.
15
16 For named uniform blocks the values are stored according to the reflected
17 layout of the block, ready for use by shaders.  For the default uniform block,
18 the location of the uniform is multiplied by 16 to obtain the memory offset.
19
20 Applications normally don't need to deal with UniformBlocks directly.  They're
21 managed by the ProgramData class, which provides a higher-level interface for
22 setting uniform values.
23 */
24 class UniformBlock: public UniformBlockBackend, public Bufferable
25 {
26 private:
27         std::vector<char> data;
28
29 public:
30         UniformBlock(const ReflectData::UniformBlockInfo &);
31
32         virtual std::size_t get_data_size() const { return data.size(); }
33         virtual const void *get_data_pointer() const { return &data[0]; }
34 private:
35         virtual std::size_t get_alignment() const;
36
37 public:
38         void store(const ReflectData::UniformInfo &, std::size_t, const void *);
39         void check_store_range(std::size_t, std::size_t);
40 };
41
42 } // namespace GL
43 } // namespace Msp
44
45 #endif