X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fzsortedscene.h;fp=source%2Fzsortedscene.h;h=f9f6f7eed40bd9cfa527540c5417c6fbce3ae75e;hp=0000000000000000000000000000000000000000;hb=c87860db3b23a98eda1adfe59acddffdb6eb8420;hpb=78328c5f6e4dcbe883a3f5e4fe0974ab490be3f7 diff --git a/source/zsortedscene.h b/source/zsortedscene.h new file mode 100644 index 00000000..f9f6f7ee --- /dev/null +++ b/source/zsortedscene.h @@ -0,0 +1,57 @@ +#ifndef MSP_GL_ZSORTEDSCENE_H_ +#define MSP_GL_ZSORTEDSCENE_H_ + +#include "simplescene.h" + +namespace Msp { +namespace GL { + +enum SortOrder +{ + FRONT_TO_BACK, + BACK_TO_FRONT +}; + +enum DepthReference +{ + CLOSEST, + CENTER, + FURTHEST +}; + +/** +Sorts renderables by their distance from the camera before rendering. Requires +renderables to have a matrix. +*/ +class ZSortedScene: public SimpleScene +{ +private: + struct DepthRenderable + { + float depth; + const Renderable *renderable; + + DepthRenderable(float, const Renderable *); + + bool operator<(const DepthRenderable &o) const { return depth