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
34 struct SortedRenderable
36 Renderable *renderable;
40 SortedRenderable(Renderable *);
42 bool operator<(const SortedRenderable &o) const { return depth<o.depth; }
45 std::set<Renderable *> renderables;
47 DepthReference reference;
48 mutable std::vector<SortedRenderable> 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 &, Tag = Tag()) const;