X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=effect.cpp;h=927acd52e7934774ba0b43eea4b61202f7b9bf4e;hp=f89b1a99c8c2350d8d5a82ddde26d701c5d373e2;hb=430394b9790b9a7083aac549f607047499788710;hpb=e61807327b9a1f98f39dd5e1496254905f78e581;ds=sidebyside diff --git a/effect.cpp b/effect.cpp index f89b1a9..927acd5 100644 --- a/effect.cpp +++ b/effect.cpp @@ -1,3 +1,4 @@ +#include #include #include #include "effect.h" @@ -47,3 +48,24 @@ void Effect::register_vec3(const std::string &key, float *values) params_vec3[key] = values; } +// Output convenience uniforms for each parameter. +// These will be filled in per-frame. +std::string Effect::output_convenience_uniforms() +{ + std::string output = ""; + for (std::map::const_iterator it = params_float.begin(); + it != params_float.end(); + ++it) { + char buf[256]; + sprintf(buf, "uniform float PREFIX(%s);\n", it->first.c_str()); + output.append(buf); + } + for (std::map::const_iterator it = params_vec3.begin(); + it != params_vec3.end(); + ++it) { + char buf[256]; + sprintf(buf, "uniform vec3 PREFIX(%s);\n", it->first.c_str()); + output.append(buf); + } + return output; +}