1 #ifndef MSP_GL_ZSORTEDSCENE_H_
2 #define MSP_GL_ZSORTEDSCENE_H_
25 Sorts renderables by their distance from the camera before rendering. Requires
26 renderables to have a matrix.
28 class ZSortedScene: public Scene
31 struct SortedRenderable
33 Renderable *renderable;
37 SortedRenderable(Renderable *);
39 bool operator<(const SortedRenderable &o) const { return depth<o.depth; }
42 typedef std::set<Renderable *> RenderableSet;
43 typedef std::vector<SortedRenderable> SortedArray;
45 RenderableSet renderables;
47 DepthReference reference;
48 mutable SortedArray sorted_cache;
53 virtual void add(Renderable &);
54 virtual void remove(Renderable &);
56 /// Sets the sort order. Default is back to front.
57 void set_order(SortOrder);
59 /// Sets the reference point for sorting. Default is furthest from camera.
60 void set_reference(DepthReference);
63 void populate_cache() const;
66 virtual void setup_frame(Renderer &);
67 virtual void finish_frame();
69 virtual void render(Renderer &, const Tag & = Tag()) const;