delete texturing;
}
+void RenderPass::ensure_private_shader_data()
+{
+ if(!shprog)
+ throw invalid_operation("RenderPass::ensure_private_shader_data");
+
+ if(!shdata)
+ shdata = new ProgramData(shprog);
+ else if(shdata.refcount() > 1)
+ shdata = new ProgramData(*shdata);
+}
+
void RenderPass::set_shader_program(const Program *prog, const ProgramData *data)
{
shprog = prog;
{
texunit(i);
obj.tex_names[n] = i;
+ obj.ensure_private_shader_data();
+ obj.shdata->uniform(n, static_cast<int>(i));
}
void RenderPass::Loader::uniforms()
{
- if(!obj.shprog)
- throw invalid_operation("RenderPass::Loader::uniforms");
+ obj.ensure_private_shader_data();
RefPtr<ProgramData> shd = new ProgramData(obj.shprog);
load_sub(*shd);
obj.shdata = shd.release();
RenderPass &operator=(const RenderPass &);
~RenderPass();
+private:
+ void ensure_private_shader_data();
+
+public:
void set_shader_program(const Program *, const ProgramData *);
const Program *get_shader_program() const { return shprog; }
const ProgramData *get_shader_data() const { return shdata.get(); }