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;
void Scene::render(const Tag &tag) const
{
- for(set<const Renderable *>::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
+ for(set<const Renderable *, Compare>::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()<b->get_order();
+ return a<b;
+}
+
} // namespace GL
} // namespace Msp
class Scene: public Renderable
{
private:
- std::set<const Renderable *> renderables;
+ struct Compare
+ {
+ bool operator()(const Renderable *, const Renderable *) const;
+ };
+
+ std::set<const Renderable *, Compare> renderables;
public:
void add(const Renderable &);