6 bool Effect::set_int(const std::string &key, int value)
8 if (params_int.count(key) == 0) {
11 *params_int[key] = value;
15 bool Effect::set_float(const std::string &key, float value)
17 if (params_float.count(key) == 0) {
20 *params_float[key] = value;
24 bool Effect::set_vec3(const std::string &key, const float *values)
26 if (params_vec3.count(key) == 0) {
29 memcpy(params_vec3[key], values, sizeof(float) * 3);
33 void Effect::register_int(const std::string &key, int *value)
35 assert(params_int.count(key) == 0);
36 params_int[key] = value;
39 void Effect::register_float(const std::string &key, float *value)
41 assert(params_float.count(key) == 0);
42 params_float[key] = value;
45 void Effect::register_vec3(const std::string &key, float *values)
47 assert(params_vec3.count(key) == 0);
48 params_vec3[key] = values;
51 // Output convenience uniforms for each parameter.
52 // These will be filled in per-frame.
53 std::string Effect::output_convenience_uniforms()
55 std::string output = "";
56 for (std::map<std::string, float*>::const_iterator it = params_float.begin();
57 it != params_float.end();
60 sprintf(buf, "uniform float PREFIX(%s);\n", it->first.c_str());
63 for (std::map<std::string, float*>::const_iterator it = params_vec3.begin();
64 it != params_vec3.end();
67 sprintf(buf, "uniform vec3 PREFIX(%s);\n", it->first.c_str());