3 This file is part of libmspgl
4 Copyright © 2010-2011 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
9 #include "orderedscene.h"
14 void OrderedScene::add(const Renderable &r)
16 renderables.push_back(&r);
19 void OrderedScene::remove(const Renderable &r)
21 RenderableList::iterator end = std::remove(renderables.begin(), renderables.end(), &r);
22 renderables.erase(end, renderables.end());
25 void OrderedScene::prepend(const Renderable &r)
27 renderables.push_front(&r);
30 void OrderedScene::insert(unsigned index, const Renderable &r)
32 RenderableList::iterator i = renderables.begin();
33 for(; (i!=renderables.end() && index); ++i, --index) ;
34 renderables.insert(i, &r);
37 void OrderedScene::insert_after(const Renderable &after, const Renderable &r)
39 RenderableList::iterator i = renderables.begin();
40 for(; (i!=renderables.end() && *i!=&after); ++i) ;
41 renderables.insert(i, &r);
44 void OrderedScene::render(Renderer &renderer, const Tag &tag) const
46 for(RenderableList::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
47 (*i)->render(renderer, tag);