From: Mikko Rasa Date: Wed, 27 Feb 2008 14:09:02 +0000 (+0000) Subject: Allow Renderables in a Scene to specify ordering X-Git-Tag: 0.9~10 X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=commitdiff_plain;h=6a135773515b020ea3f163a11d06150ae5c0e69f Allow Renderables in a Scene to specify ordering --- diff --git a/source/renderable.h b/source/renderable.h index 00b8b901..aeee1666 100644 --- a/source/renderable.h +++ b/source/renderable.h @@ -17,6 +17,7 @@ namespace GL { class Renderable { public: + virtual int get_order() const { return 0; } virtual bool has_pass(const Tag &tag) const =0; virtual void render(const Tag &tag=Tag()) const =0; diff --git a/source/scene.cpp b/source/scene.cpp index 20399daf..607166d5 100644 --- a/source/scene.cpp +++ b/source/scene.cpp @@ -24,10 +24,18 @@ void Scene::remove(const Renderable &r) void Scene::render(const Tag &tag) const { - for(set::const_iterator i=renderables.begin(); i!=renderables.end(); ++i) + for(set::const_iterator i=renderables.begin(); i!=renderables.end(); ++i) if((*i)->has_pass(tag)) (*i)->render(tag); } + +bool Scene::Compare::operator()(const Renderable *a, const Renderable *b) const +{ + if(a->get_order()!=b->get_order()) + return a->get_order()get_order(); + return a renderables; + struct Compare + { + bool operator()(const Renderable *, const Renderable *) const; + }; + + std::set renderables; public: void add(const Renderable &);