uniform(name, new UniformArray<UniformMatrix4x4f>(n, v));
}
-const UniformBlock &ProgramData::get_block(const Program &prog, const string &name) const
+const UniformBlock &ProgramData::get_block(const Program &prog, const Program::UniformBlockInfo *info) const
{
if(modified)
{
modified = false;
}
- const Program::UniformBlockInfo *info = 0;
- unsigned layout_hash;
- if(!name.empty())
- {
- info = &prog.get_uniform_block_info(name);
- layout_hash = info->layout_hash;
- }
- else
- layout_hash = prog.get_uniform_layout_hash();
+ unsigned layout_hash = (info ? info->layout_hash : prog.get_uniform_layout_hash());
map<unsigned, Block>::iterator i = blocks.find(layout_hash);
if(i==blocks.end())
return block;
}
+const UniformBlock &ProgramData::get_block(const Program &prog, const string &name) const
+{
+ if(name.empty())
+ return get_block(prog, 0);
+ else
+ return get_block(prog, &prog.get_uniform_block_info(name));
+}
+
void ProgramData::apply() const
{
const Program *prog = Program::current();
const Program::UniformBlockMap &prog_blocks = prog->get_uniform_blocks();
for(Program::UniformBlockMap::const_iterator i=prog_blocks.begin(); i!=prog_blocks.end(); ++i)
{
- const UniformBlock &block = get_block(*prog, i->second.name);
+ const UniformBlock &block = get_block(*prog, &i->second);
block.apply(i->second.bind_point);
}
- const UniformBlock &block = get_block(*prog, string());
+ const UniformBlock &block = get_block(*prog, 0);
block.apply(-1);
}
#include <map>
#include <msp/datafile/objectloader.h>
+#include "program.h"
namespace Msp {
namespace GL {
class Buffer;
class Color;
class Matrix;
-class Program;
class Uniform;
class UniformBlock;
class Vector3;
void uniform4_array(const std::string &, unsigned, const float *);
void uniform_matrix4_array(const std::string &, unsigned, const float *);
+private:
+ const UniformBlock &get_block(const Program &, const Program::UniformBlockInfo *) const;
+public:
const UniformBlock &get_block(const Program &, const std::string &) const;
void apply() const;