1 #ifndef MSP_GL_ZSORTEDSCENE_H_
2 #define MSP_GL_ZSORTEDSCENE_H_
25 A scene which sorts renderables by their distance from the camera before
28 Renderables must have valid model matrices to be sorted. Those without a
29 matrix are sorted as closest to the camera.
31 class ZSortedScene: public Scene
37 struct SortedRenderable
39 Renderable *renderable;
40 bool in_frustum = false;
43 SortedRenderable(Renderable *r): renderable(r) { }
45 bool operator<(const SortedRenderable &o) const { return depth<o.depth; }
48 std::vector<Renderable *> content;
49 SortOrder order = BACK_TO_FRONT;
50 DepthReference reference = FURTHEST;
51 mutable std::map<const Camera *, std::vector<SortedRenderable> > sorted_cache;
54 virtual void add(Renderable &);
55 virtual void remove(Renderable &);
57 /// Sets the sort order. Default is back to front.
58 void set_order(SortOrder);
60 /// Sets the reference point for sorting. Default is furthest from camera.
61 void set_reference(DepthReference);
63 virtual void setup_frame(Renderer &);
64 virtual void finish_frame();
66 virtual void render(Renderer &, Tag = Tag()) const;