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