]> git.tdb.fi Git - libs/gl.git/blob - source/effects/effect.h
bc9e19ec818f2a392889866bdf36428c7c00024b
[libs/gl.git] / source / effects / effect.h
1 #ifndef MSP_GL_EFFECT_H_
2 #define MSP_GL_EFFECT_H_
3
4 #include <set>
5 #include <msp/core/refptr.h>
6 #include "renderable.h"
7
8 namespace Msp {
9 namespace GL {
10
11 class Sampler;
12
13 /**
14 Effects are used to wrap other renderables and give them additional visual
15 properties.  An Effect's render method should set up the necessary state, call
16 the wrapped Renderable's render method, and clean up after itself.
17 */
18 class Effect: public Renderable
19 {
20 protected:
21         Renderable &renderable;
22         std::set<Tag> enabled_passes;
23
24 private:
25         static WeakPtr<Sampler> linear_sampler;
26
27 protected:
28         Effect(Renderable &);
29 public:
30         virtual ~Effect() { }
31
32         void enable_for_pass(const Tag &);
33         void disable_for_pass(const Tag &);
34
35         virtual const Matrix *get_matrix() const { return renderable.get_matrix(); }
36         virtual const Geometry::BoundingSphere<float, 3> *get_bounding_sphere() const { return renderable.get_bounding_sphere(); }
37
38         virtual void setup_frame(Renderer &r) { renderable.setup_frame(r); }
39         virtual void finish_frame() { renderable.finish_frame(); }
40
41 protected:
42         static RefPtr<Sampler> get_linear_sampler();
43 };
44
45 } // namespace GL
46 } // namespace Msp
47
48 #endif