X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Funiformblock.h;fp=source%2Fcore%2Funiformblock.h;h=c8b8d36a3d8e2deceaf8881d5dbb83ec0ae1f825;hb=7aaec9a70b8d7733429bec043f8e33e02956f266;hp=0000000000000000000000000000000000000000;hpb=bec07999d95b76f4b47cffcc564d0cd0afc0435e;p=libs%2Fgl.git diff --git a/source/core/uniformblock.h b/source/core/uniformblock.h new file mode 100644 index 00000000..c8b8d36a --- /dev/null +++ b/source/core/uniformblock.h @@ -0,0 +1,53 @@ +#ifndef MSP_GL_UNIFORMBLOCK_H_ +#define MSP_GL_UNIFORMBLOCK_H_ + +#include +#include +#include "bufferable.h" +#include "program.h" +#include "vector.h" + +namespace Msp { +namespace GL { + +class BufferRange; +class Matrix; +class Uniform; +struct Color; + +/** +Stores uniforms with a specific layout. Both named and default uniform blocks +are supported. +*/ +class UniformBlock: public Bufferable +{ +private: + std::map uniforms; + unsigned size; + std::vector data; + mutable BufferRange *buf_range; + + UniformBlock(const UniformBlock &); + UniformBlock &operator=(const UniformBlock &); +public: + UniformBlock(); + UniformBlock(unsigned); + ~UniformBlock(); + +private: + virtual unsigned get_data_size() const { return size; } + virtual const void *get_data_pointer() const { return &data[0]; } + virtual unsigned get_alignment() const; + virtual void location_changed(Buffer *, unsigned, unsigned) const; + +public: + void attach(int, const Uniform &); + void attach(const Program::UniformInfo &, const Uniform &); + + void apply(int) const; +}; + +} // namespace GL +} // namespace Msp + +#endif