]> git.tdb.fi Git - libs/gl.git/commitdiff
Make RenderPass shprog and shdata settable from code
authorMikko Rasa <tdb@tdb.fi>
Wed, 22 Aug 2012 12:28:40 +0000 (15:28 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 22 Aug 2012 12:28:40 +0000 (15:28 +0300)
For consistency with other similar interfaces, the pointers are now
const.  As a consequence, a uniforms statement in a datafile overrides
any previous uniforms.

source/renderpass.cpp
source/renderpass.h

index b0289284033f4935066db0aafdcb07638dc9c2f2..de5ac07f8f6bcf34356eab49bb693c6c26d3ecde 100644 (file)
@@ -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<ProgramData> shd = new ProgramData;
+       load_sub(*shd);
+       obj.shdata = shd;
 }
 
 
index 5af733dc8b6ed2961510779621502377a2d8f284..ac752ae230c5c9b7d6435d2fc8de2938b3426b55 100644 (file)
@@ -57,8 +57,8 @@ private:
                void texture2d();
        };
 
-       Program *shprog;
-       ProgramData *shdata;
+       const Program *shprog;
+       RefPtr<const ProgramData> shdata;
        RefPtr<const Material> material;
        Texturing *texturing;
        std::map<std::string, unsigned> 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 *);