1 #ifndef MSP_GL_ZSORTEDSCENE_H_
2 #define MSP_GL_ZSORTEDSCENE_H_
4 #include "simplescene.h"
23 Sorts renderables by their distance from the camera before rendering. Requires
24 renderables to have a matrix.
26 class ZSortedScene: public Scene
29 struct SortedRenderable
33 const Renderable *renderable;
35 SortedRenderable(const Renderable *);
37 bool operator<(const SortedRenderable &o) const { return depth<o.depth; }
40 typedef std::set<const Renderable *> RenderableSet;
41 typedef std::vector<SortedRenderable> SortedArray;
43 RenderableSet renderables;
45 DepthReference reference;
46 mutable SortedArray sorted_cache;
51 virtual void add(const Renderable &);
52 virtual void remove(const Renderable &);
54 /// Sets the sort order. Default is back to front.
55 void set_order(SortOrder);
57 /// Sets the reference point for sorting. Default is furthest from camera.
58 void set_reference(DepthReference);
60 virtual void render(Renderer &, const Tag &) const;