X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Funiformblock.h;h=1144158d2ee3ae760bb994be535b8657c9650faa;hp=c8b8d36a3d8e2deceaf8881d5dbb83ec0ae1f825;hb=HEAD;hpb=7aaec9a70b8d7733429bec043f8e33e02956f266 diff --git a/source/core/uniformblock.h b/source/core/uniformblock.h index c8b8d36a..1144158d 100644 --- a/source/core/uniformblock.h +++ b/source/core/uniformblock.h @@ -1,50 +1,42 @@ #ifndef MSP_GL_UNIFORMBLOCK_H_ #define MSP_GL_UNIFORMBLOCK_H_ -#include #include +#include #include "bufferable.h" -#include "program.h" -#include "vector.h" +#include "reflectdata.h" +#include "uniformblock_backend.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. +Stores uniform values in a block of memory. + +For named uniform blocks the values are stored according to the reflected +layout of the block, ready for use by shaders. For the default uniform block, +the location of the uniform is multiplied by 16 to obtain the memory offset. + +Applications normally don't need to deal with UniformBlocks directly. They're +managed by the ProgramData class, which provides a higher-level interface for +setting uniform values. */ -class UniformBlock: public Bufferable +class UniformBlock: public UniformBlockBackend, 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(); + UniformBlock(const ReflectData::UniformBlockInfo &); -private: - virtual unsigned get_data_size() const { return size; } + virtual std::size_t get_data_size() const { return data.size(); } virtual const void *get_data_pointer() const { return &data[0]; } - virtual unsigned get_alignment() const; - virtual void location_changed(Buffer *, unsigned, unsigned) const; +private: + virtual std::size_t get_alignment() const; public: - void attach(int, const Uniform &); - void attach(const Program::UniformInfo &, const Uniform &); - - void apply(int) const; + void store(const ReflectData::UniformInfo &, std::size_t, const void *); + void check_store_range(std::size_t, std::size_t); }; } // namespace GL