From: Mikko Rasa Date: Wed, 22 Aug 2012 12:28:40 +0000 (+0300) Subject: Make RenderPass shprog and shdata settable from code X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=c10c05365187cf717e3e95c446fdc6a890b114bd;p=libs%2Fgl.git Make RenderPass shprog and shdata settable from code For consistency with other similar interfaces, the pointers are now const. As a consequence, a uniforms statement in a datafile overrides any previous uniforms. --- diff --git a/source/renderpass.cpp b/source/renderpass.cpp index b0289284..de5ac07f 100644 --- a/source/renderpass.cpp +++ b/source/renderpass.cpp @@ -32,10 +32,16 @@ RenderPass::RenderPass(const RenderPass &other): RenderPass::~RenderPass() { - delete shdata; delete texturing; } +void RenderPass::set_shader_program(const Program *prog, const ProgramData *data) +{ + shprog = prog; + shdata = data; + shdata.keep(); +} + void RenderPass::set_material(const Material *mat) { material = mat; @@ -112,9 +118,9 @@ void RenderPass::Loader::uniforms() { if(!obj.shprog) throw invalid_operation("RenderPass::Loader::uniforms"); - if(!obj.shdata) - obj.shdata = new ProgramData; - load_sub(*obj.shdata); + RefPtr shd = new ProgramData; + load_sub(*shd); + obj.shdata = shd; } diff --git a/source/renderpass.h b/source/renderpass.h index 5af733dc..ac752ae2 100644 --- a/source/renderpass.h +++ b/source/renderpass.h @@ -57,8 +57,8 @@ private: void texture2d(); }; - Program *shprog; - ProgramData *shdata; + const Program *shprog; + RefPtr shdata; RefPtr material; Texturing *texturing; std::map tex_names; @@ -69,8 +69,9 @@ public: RenderPass(const RenderPass &); ~RenderPass(); + void set_shader_program(const Program *, const ProgramData *); const Program *get_shader_program() const { return shprog; } - const ProgramData *get_shader_data() const { return shdata; } + const ProgramData *get_shader_data() const { return shdata.get(); } void set_material(const Material *); const Material *get_material() const { return material.get(); } void set_texture(unsigned, const Texture *);