X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fenvironmentmap.h;fp=source%2Fenvironmentmap.h;h=9c4c4d15df4b4c6d342805973df4368944688a96;hp=0000000000000000000000000000000000000000;hb=131bec9b254f5ba50dcaf7e6192baab9e9ccba6f;hpb=bd141418a0712feeb64bcaff7f57e29913b0317b diff --git a/source/environmentmap.h b/source/environmentmap.h new file mode 100644 index 00000000..9c4c4d15 --- /dev/null +++ b/source/environmentmap.h @@ -0,0 +1,51 @@ +#ifndef MSP_GL_ENVIRONMENTMAP_H_ +#define MSP_GL_ENVIRONMENTMAP_H_ + +#include "camera.h" +#include "effect.h" +#include "framebuffer.h" +#include "matrix.h" +#include "programdata.h" +#include "renderbuffer.h" +#include "texturecube.h" +#include "vector.h" + +namespace Msp { +namespace GL { + +class Renderable; + +/** +Creates a cube map texture of the surroundings of the renderable. This texture +can then be used to implement effects such as reflections or refractions. + +If the EnvironmentMap is used in a Pipeline, it's worth noting that the cube +map will be prepared outside of any rendering pass. It's recommended to use +another Pipeline to define which passes should be used to render the +environment. +*/ +class EnvironmentMap: public Effect +{ +private: + unsigned size; + Renderable &environment; + TextureCube env_tex; + Renderbuffer depth_buf; + mutable Framebuffer fbo[6]; + mutable Camera camera; + mutable ProgramData shdata; + mutable bool rendered; + +public: + EnvironmentMap(unsigned size, Renderable &rend, Renderable &env); + + virtual void setup_frame() const; + virtual void finish_frame() const; + + virtual void render(Renderer &, const Tag &) const; +}; + +} // namespace GL +} // namespace Msp + +#endif