]> git.sesse.net Git - movit/blob - effect.h
Flip some need bits in the conversion effects.
[movit] / effect.h
1 #ifndef _EFFECT_H
2 #define _EFFECT_H 1
3
4 #include <map>
5 #include <string>
6
7 #include <GL/gl.h>
8
9 // Can alias on a float[3].
10 struct RGBTriplet {
11         RGBTriplet(float r, float g, float b)
12                 : r(r), g(g), b(b) {}
13
14         float r, g, b;
15 };
16
17 // Convenience functions that deal with prepending the prefix..
18 void set_uniform_float(GLhandleARB glsl_program_num, const std::string &prefix, const std::string &key, float value);
19 void set_uniform_vec3(GLhandleARB glsl_program_num, const std::string &prefix, const std::string &key, const float *values);
20
21 class Effect {
22 public: 
23         virtual bool needs_linear_light() { return true; }
24         virtual bool needs_srgb_primaries() { return true; }
25         virtual bool needs_many_samples() { return false; }
26         virtual bool needs_mipmaps() { return false; }
27
28         virtual std::string output_convenience_uniforms();
29         virtual std::string output_glsl() = 0;
30
31         virtual void set_uniforms(GLhandleARB glsl_program_num, const std::string& prefix);
32
33         // Neither of these take ownership.
34         bool set_int(const std::string&, int value);
35         bool set_float(const std::string &key, float value);
36         bool set_vec3(const std::string &key, const float *values);
37
38 protected:
39         // Neither of these take ownership.
40         void register_int(const std::string &key, int *value);
41         void register_float(const std::string &key, float *value);
42         void register_vec3(const std::string &key, float *values);
43         
44 private:
45         std::map<std::string, int *> params_int;
46         std::map<std::string, float *> params_float;
47         std::map<std::string, float *> params_vec3;
48 };
49
50 #endif // !defined(_EFFECT_H)