1 #ifndef MSP_GL_UNIFORMBLOCK_H_
2 #define MSP_GL_UNIFORMBLOCK_H_
6 #include "bufferable.h"
19 Stores uniforms with a specific layout. Both named and default uniform blocks
22 class UniformBlock: public NonCopyable
27 virtual ~UniformBlock() { }
29 virtual void attach(const Program::UniformInfo &, const Uniform &) = 0;
32 /** Stores uniforms for the default uniform block. Uniforms are associated
33 with locations, as returned by Program::get_uniform_location. */
34 class DefaultUniformBlock: public UniformBlock
37 std::vector<const Uniform *> uniforms;
40 DefaultUniformBlock();
42 virtual void attach(const Program::UniformInfo &, const Uniform &);
43 void attach(int, const Uniform &);
47 /** Stores uniforms for a buffer-backed uniform block. Uniform values are
48 stored in a memory block which can be uploaded into a buffer and bound for use
50 class BufferBackedUniformBlock: public UniformBlock, public Bufferable
54 std::vector<char> data;
57 BufferBackedUniformBlock(unsigned);
59 virtual unsigned get_data_size() const { return size; }
61 virtual const void *get_data_pointer() const { return &data[0]; }
62 virtual unsigned get_alignment() const;
65 void attach(const Program::UniformInfo &, const Uniform &);