X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=effect.h;h=32d8f402f09598c88f2f4a989a9c70ecdead7206;hp=deeaae45264fddf57a3ffd5c5a57ee3da64b732a;hb=96a1cff51a8b7dc45ebe725e0d0685eecce31331;hpb=e61807327b9a1f98f39dd5e1496254905f78e581 diff --git a/effect.h b/effect.h index deeaae4..32d8f40 100644 --- a/effect.h +++ b/effect.h @@ -4,6 +4,29 @@ #include #include +#include + +// Can alias on a float[2]. +struct Point2D { + Point2D(float x, float y) + : x(x), y(y) {} + + float x, y; +}; + +// Can alias on a float[3]. +struct RGBTriplet { + RGBTriplet(float r, float g, float b) + : r(r), g(g), b(b) {} + + float r, g, b; +}; + +// Convenience functions that deal with prepending the prefix. +void set_uniform_float(GLuint glsl_program_num, const std::string &prefix, const std::string &key, float value); +void set_uniform_vec2(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values); +void set_uniform_vec3(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values); + class Effect { public: virtual bool needs_linear_light() { return true; } @@ -11,20 +34,28 @@ public: virtual bool needs_many_samples() { return false; } virtual bool needs_mipmaps() { return false; } + virtual std::string output_convenience_uniforms(); + virtual std::string output_glsl() = 0; + + virtual void set_uniforms(GLuint glsl_program_num, const std::string& prefix); + // Neither of these take ownership. bool set_int(const std::string&, int value); bool set_float(const std::string &key, float value); + bool set_vec2(const std::string &key, const float *values); bool set_vec3(const std::string &key, const float *values); protected: // Neither of these take ownership. void register_int(const std::string &key, int *value); void register_float(const std::string &key, float *value); + void register_vec2(const std::string &key, float *values); void register_vec3(const std::string &key, float *values); private: std::map params_int; std::map params_float; + std::map params_vec2; std::map params_vec3; };