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;
46 SortOrder order = BACK_TO_FRONT;
47 DepthReference reference = FURTHEST;
48 mutable std::vector<SortedRenderable> sorted_cache;
51 virtual void add(Renderable &);
52 virtual void remove(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);
61 void populate_cache() const;
64 virtual void setup_frame(Renderer &);
65 virtual void finish_frame();
67 virtual void render(Renderer &, Tag = Tag()) const;