2 #include "orderedscene.h"
8 void OrderedScene::add(Renderable &r)
10 renderables.push_back(&r);
13 void OrderedScene::remove(Renderable &r)
15 RenderableList::iterator end = std::remove(renderables.begin(), renderables.end(), &r);
16 renderables.erase(end, renderables.end());
19 void OrderedScene::prepend(Renderable &r)
21 renderables.push_front(&r);
24 void OrderedScene::insert(unsigned index, Renderable &r)
26 RenderableList::iterator i = renderables.begin();
27 for(; (i!=renderables.end() && index); ++i, --index) ;
28 renderables.insert(i, &r);
31 void OrderedScene::insert_after(Renderable &after, Renderable &r)
33 RenderableList::iterator i = renderables.begin();
34 for(; (i!=renderables.end() && *i!=&after); ++i) ;
35 renderables.insert(i, &r);
38 void OrderedScene::setup_frame(Renderer &renderer)
40 for(RenderableList::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
41 (*i)->setup_frame(renderer);
44 void OrderedScene::finish_frame()
46 for(RenderableList::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
50 void OrderedScene::render(Renderer &renderer, Tag tag) const
52 if(setup_frustum(renderer))
54 for(RenderableList::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
55 if(!frustum_cull(**i))
56 renderer.render(**i, tag);
60 for(RenderableList::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
61 renderer.render(**i, tag);