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_ivec2(const string &key, const int *values)
26 if (params_ivec2.count(key) == 0) {
29 memcpy(params_ivec2[key], values, sizeof(int) * 2);
33 bool Effect::set_float(const string &key, float value)
35 if (params_float.count(key) == 0) {
38 *params_float[key] = value;
42 bool Effect::set_vec2(const string &key, const float *values)
44 if (params_vec2.count(key) == 0) {
47 memcpy(params_vec2[key], values, sizeof(float) * 2);
51 bool Effect::set_vec3(const string &key, const float *values)
53 if (params_vec3.count(key) == 0) {
56 memcpy(params_vec3[key], values, sizeof(float) * 3);
60 bool Effect::set_vec4(const string &key, const float *values)
62 if (params_vec4.count(key) == 0) {
65 memcpy(params_vec4[key], values, sizeof(float) * 4);
69 void Effect::register_int(const string &key, int *value)
71 assert(params_int.count(key) == 0);
72 params_int[key] = value;
73 register_uniform_int(key, value);
76 void Effect::register_ivec2(const string &key, int *values)
78 assert(params_ivec2.count(key) == 0);
79 params_ivec2[key] = values;
80 register_uniform_ivec2(key, values);
83 void Effect::register_float(const string &key, float *value)
85 assert(params_float.count(key) == 0);
86 params_float[key] = value;
87 register_uniform_float(key, value);
90 void Effect::register_vec2(const string &key, float *values)
92 assert(params_vec2.count(key) == 0);
93 params_vec2[key] = values;
94 register_uniform_vec2(key, values);
97 void Effect::register_vec3(const string &key, float *values)
99 assert(params_vec3.count(key) == 0);
100 params_vec3[key] = values;
101 register_uniform_vec3(key, values);
104 void Effect::register_vec4(const string &key, float *values)
106 assert(params_vec4.count(key) == 0);
107 params_vec4[key] = values;
108 register_uniform_vec4(key, values);
111 void Effect::set_gl_state(GLuint glsl_program_num, const string& prefix, unsigned *sampler_num) {}
113 void Effect::clear_gl_state() {}
115 void Effect::register_uniform_sampler2d(const std::string &key, const GLint *value)
117 Uniform<int> uniform;
119 uniform.value = value;
120 uniform.num_values = 1;
121 uniform.location = -1;
122 uniforms_sampler2d.push_back(uniform);
125 void Effect::register_uniform_bool(const std::string &key, const bool *value)
127 Uniform<bool> uniform;
129 uniform.value = value;
130 uniform.num_values = 1;
131 uniform.location = -1;
132 uniforms_bool.push_back(uniform);
135 void Effect::register_uniform_int(const std::string &key, const int *value)
137 Uniform<int> uniform;
139 uniform.value = value;
140 uniform.num_values = 1;
141 uniform.location = -1;
142 uniforms_int.push_back(uniform);
145 void Effect::register_uniform_ivec2(const std::string &key, const int *values)
147 Uniform<int> uniform;
149 uniform.value = values;
150 uniform.num_values = 1;
151 uniform.location = -1;
152 uniforms_ivec2.push_back(uniform);
155 void Effect::register_uniform_float(const std::string &key, const float *value)
157 Uniform<float> uniform;
159 uniform.value = value;
160 uniform.num_values = 1;
161 uniform.location = -1;
162 uniforms_float.push_back(uniform);
165 void Effect::register_uniform_vec2(const std::string &key, const float *values)
167 Uniform<float> uniform;
169 uniform.value = values;
170 uniform.num_values = 1;
171 uniform.location = -1;
172 uniforms_vec2.push_back(uniform);
175 void Effect::register_uniform_vec3(const std::string &key, const float *values)
177 Uniform<float> uniform;
179 uniform.value = values;
180 uniform.num_values = 1;
181 uniform.location = -1;
182 uniforms_vec3.push_back(uniform);
185 void Effect::register_uniform_vec4(const std::string &key, const float *values)
187 Uniform<float> uniform;
189 uniform.value = values;
190 uniform.num_values = 1;
191 uniform.location = -1;
192 uniforms_vec4.push_back(uniform);
195 void Effect::register_uniform_float_array(const std::string &key, const float *values, size_t num_values)
197 Uniform<float> uniform;
199 uniform.value = values;
200 uniform.num_values = num_values;
201 uniform.location = -1;
202 uniforms_float_array.push_back(uniform);
205 void Effect::register_uniform_vec2_array(const std::string &key, const float *values, size_t num_values)
207 Uniform<float> uniform;
209 uniform.value = values;
210 uniform.num_values = num_values;
211 uniform.location = -1;
212 uniforms_vec2_array.push_back(uniform);
215 void Effect::register_uniform_vec3_array(const std::string &key, const float *values, size_t num_values)
217 Uniform<float> uniform;
219 uniform.value = values;
220 uniform.num_values = num_values;
221 uniform.location = -1;
222 uniforms_vec3_array.push_back(uniform);
225 void Effect::register_uniform_vec4_array(const std::string &key, const float *values, size_t num_values)
227 Uniform<float> uniform;
229 uniform.value = values;
230 uniform.num_values = num_values;
231 uniform.location = -1;
232 uniforms_vec4_array.push_back(uniform);
235 void Effect::register_uniform_mat3(const std::string &key, const Matrix3d *matrix)
237 Uniform<Matrix3d> uniform;
239 uniform.value = matrix;
240 uniform.num_values = 1;
241 uniform.location = -1;
242 uniforms_mat3.push_back(uniform);