8 #include "effect_util.h"
10 using namespace Eigen;
15 bool Effect::set_int(const string &key, int value)
17 if (params_int.count(key) == 0) {
20 *params_int[key] = value;
24 bool Effect::set_float(const string &key, float value)
26 if (params_float.count(key) == 0) {
29 *params_float[key] = value;
33 bool Effect::set_vec2(const string &key, const float *values)
35 if (params_vec2.count(key) == 0) {
38 memcpy(params_vec2[key], values, sizeof(float) * 2);
42 bool Effect::set_vec3(const string &key, const float *values)
44 if (params_vec3.count(key) == 0) {
47 memcpy(params_vec3[key], values, sizeof(float) * 3);
51 bool Effect::set_vec4(const string &key, const float *values)
53 if (params_vec4.count(key) == 0) {
56 memcpy(params_vec4[key], values, sizeof(float) * 4);
60 void Effect::register_int(const string &key, int *value)
62 assert(params_int.count(key) == 0);
63 params_int[key] = value;
66 void Effect::register_float(const string &key, float *value)
68 assert(params_float.count(key) == 0);
69 params_float[key] = value;
70 register_uniform_float(key, value);
73 void Effect::register_vec2(const string &key, float *values)
75 assert(params_vec2.count(key) == 0);
76 params_vec2[key] = values;
77 register_uniform_vec2(key, values);
80 void Effect::register_vec3(const string &key, float *values)
82 assert(params_vec3.count(key) == 0);
83 params_vec3[key] = values;
84 register_uniform_vec3(key, values);
87 void Effect::register_vec4(const string &key, float *values)
89 assert(params_vec4.count(key) == 0);
90 params_vec4[key] = values;
91 register_uniform_vec4(key, values);
94 void Effect::set_gl_state(GLuint glsl_program_num, const string& prefix, unsigned *sampler_num) {}
96 void Effect::clear_gl_state() {}
98 void Effect::register_uniform_sampler2d(const std::string &key, const GLint *value)
100 Uniform<int> uniform;
102 uniform.value = value;
103 uniform.num_values = 1;
104 uniform.location = -1;
105 uniforms_sampler2d.push_back(uniform);
108 void Effect::register_uniform_bool(const std::string &key, const bool *value)
110 Uniform<bool> uniform;
112 uniform.value = value;
113 uniform.num_values = 1;
114 uniform.location = -1;
115 uniforms_bool.push_back(uniform);
118 void Effect::register_uniform_int(const std::string &key, const int *value)
120 Uniform<int> uniform;
122 uniform.value = value;
123 uniform.num_values = 1;
124 uniform.location = -1;
125 uniforms_int.push_back(uniform);
128 void Effect::register_uniform_float(const std::string &key, const float *value)
130 Uniform<float> uniform;
132 uniform.value = value;
133 uniform.num_values = 1;
134 uniform.location = -1;
135 uniforms_float.push_back(uniform);
138 void Effect::register_uniform_vec2(const std::string &key, const float *values)
140 Uniform<float> uniform;
142 uniform.value = values;
143 uniform.num_values = 1;
144 uniform.location = -1;
145 uniforms_vec2.push_back(uniform);
148 void Effect::register_uniform_vec3(const std::string &key, const float *values)
150 Uniform<float> uniform;
152 uniform.value = values;
153 uniform.num_values = 1;
154 uniform.location = -1;
155 uniforms_vec3.push_back(uniform);
158 void Effect::register_uniform_vec4(const std::string &key, const float *values)
160 Uniform<float> uniform;
162 uniform.value = values;
163 uniform.num_values = 1;
164 uniform.location = -1;
165 uniforms_vec4.push_back(uniform);
168 void Effect::register_uniform_vec2_array(const std::string &key, const float *values, size_t num_values)
170 Uniform<float> uniform;
172 uniform.value = values;
173 uniform.num_values = num_values;
174 uniform.location = -1;
175 uniforms_vec2_array.push_back(uniform);
178 void Effect::register_uniform_vec4_array(const std::string &key, const float *values, size_t num_values)
180 Uniform<float> uniform;
182 uniform.value = values;
183 uniform.num_values = num_values;
184 uniform.location = -1;
185 uniforms_vec4_array.push_back(uniform);
188 void Effect::register_uniform_mat3(const std::string &key, const Matrix3d *matrix)
190 Uniform<Matrix3d> uniform;
192 uniform.value = matrix;
193 uniform.num_values = 1;
194 uniform.location = -1;
195 uniforms_mat3.push_back(uniform);