]> git.tdb.fi Git - libs/gl.git/blob - source/effects/environmentmap.h
Rename Pipeline to Sequence
[libs/gl.git] / source / effects / environmentmap.h
1 #ifndef MSP_GL_ENVIRONMENTMAP_H_
2 #define MSP_GL_ENVIRONMENTMAP_H_
3
4 #include "camera.h"
5 #include "effect.h"
6 #include "framebuffer.h"
7 #include "matrix.h"
8 #include "programdata.h"
9 #include "renderbuffer.h"
10 #include "texturecube.h"
11 #include "vector.h"
12
13 namespace Msp {
14 namespace GL {
15
16 class Resources;
17
18 /**
19 Creates a cube map texture of the surroundings of the renderable.  This texture
20 can then be used to implement effects such as reflections or refractions.
21
22 If the EnvironmentMap is used in a Sequence, it's worth noting that the cube
23 map will be prepared outside of any rendering pass.  It's recommended to use
24 another Sequence to define which passes should be used to render the
25 environment.
26 */
27 class EnvironmentMap: public Effect
28 {
29 private:
30         unsigned size;
31         Renderable &environment;
32         TextureCube env_tex;
33         Renderbuffer depth_buf;
34         Framebuffer fbo[6];
35         const Sampler &sampler;
36         Camera camera;
37         mutable ProgramData shdata;
38         bool rendered;
39         unsigned update_interval;
40         unsigned update_delay;
41
42 public:
43         EnvironmentMap(Resources &, unsigned size, Renderable &rend, Renderable &env);
44
45         void set_depth_clip(float, float);
46         void set_update_interval(unsigned);
47         void queue_update();
48
49         virtual void setup_frame(Renderer &);
50         virtual void finish_frame();
51
52         virtual void render(Renderer &, Tag = Tag()) const;
53 };
54
55 } // namespace GL
56 } // namespace Msp
57
58 #endif