]> git.tdb.fi Git - libs/gl.git/commitdiff
Add setup/finish_render hooks to Object
authorMikko Rasa <tdb@tdb.fi>
Sat, 3 Nov 2012 13:32:42 +0000 (15:32 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 3 Nov 2012 13:32:42 +0000 (15:32 +0200)
source/object.cpp
source/object.h

index bd899961030095439688bf3bdc866691cfccb088..ab7afc1480aaf272589df76a6dbe31ac732dd084 100644 (file)
@@ -81,7 +81,9 @@ void Object::render(Renderer &renderer, const Tag &tag) const
        renderer.set_material(pass->get_material());
        renderer.set_texturing(pass->get_texturing());
 
+       setup_render(renderer, tag);
        meshes.front()->draw(renderer);
+       finish_render(renderer, tag);
 }
 
 void Object::render(Renderer &renderer, const ObjectInstance &inst, const Tag &tag) const
@@ -95,10 +97,12 @@ void Object::render(Renderer &renderer, const ObjectInstance &inst, const Tag &t
        renderer.set_material(pass->get_material());
        renderer.set_texturing(pass->get_texturing());
 
+       setup_render(renderer, tag);
        inst.setup_render(renderer, tag);
        unsigned lod = min<unsigned>(inst.get_level_of_detail(renderer), meshes.size()-1);
        meshes[lod]->draw(renderer);
        inst.finish_render(renderer, tag);
+       finish_render(renderer, tag);
 }
 
 const RenderPass *Object::get_pass(const Tag &tag) const
index 8a707665c8871132e4c555f8a9fc88b5108a10c6..7820d29c366df0b1392471c3e8220ce7f8fe728d 100644 (file)
@@ -66,6 +66,10 @@ public:
        called before and after drawing the mesh. */
        virtual void render(Renderer &, const ObjectInstance &, const Tag & = Tag()) const;
 
+protected:
+       virtual void setup_render(Renderer &, const Tag &) const { }
+       virtual void finish_render(Renderer &, const Tag &) const { }
+
 private:
        const RenderPass *get_pass(const Tag &) const;
 };