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;
64 register_uniform_int(key, value);
67 void Effect::register_float(const string &key, float *value)
69 assert(params_float.count(key) == 0);
70 params_float[key] = value;
71 register_uniform_float(key, value);
74 void Effect::register_vec2(const string &key, float *values)
76 assert(params_vec2.count(key) == 0);
77 params_vec2[key] = values;
78 register_uniform_vec2(key, values);
81 void Effect::register_vec3(const string &key, float *values)
83 assert(params_vec3.count(key) == 0);
84 params_vec3[key] = values;
85 register_uniform_vec3(key, values);
88 void Effect::register_vec4(const string &key, float *values)
90 assert(params_vec4.count(key) == 0);
91 params_vec4[key] = values;
92 register_uniform_vec4(key, values);
95 void Effect::set_gl_state(GLuint glsl_program_num, const string& prefix, unsigned *sampler_num) {}
97 void Effect::clear_gl_state() {}
99 void Effect::register_uniform_sampler2d(const std::string &key, const GLint *value)
101 Uniform<int> uniform;
103 uniform.value = value;
104 uniform.num_values = 1;
105 uniform.location = -1;
106 uniforms_sampler2d.push_back(uniform);
109 void Effect::register_uniform_bool(const std::string &key, const bool *value)
111 Uniform<bool> uniform;
113 uniform.value = value;
114 uniform.num_values = 1;
115 uniform.location = -1;
116 uniforms_bool.push_back(uniform);
119 void Effect::register_uniform_int(const std::string &key, const int *value)
121 Uniform<int> uniform;
123 uniform.value = value;
124 uniform.num_values = 1;
125 uniform.location = -1;
126 uniforms_int.push_back(uniform);
129 void Effect::register_uniform_float(const std::string &key, const float *value)
131 Uniform<float> uniform;
133 uniform.value = value;
134 uniform.num_values = 1;
135 uniform.location = -1;
136 uniforms_float.push_back(uniform);
139 void Effect::register_uniform_vec2(const std::string &key, const float *values)
141 Uniform<float> uniform;
143 uniform.value = values;
144 uniform.num_values = 1;
145 uniform.location = -1;
146 uniforms_vec2.push_back(uniform);
149 void Effect::register_uniform_vec3(const std::string &key, const float *values)
151 Uniform<float> uniform;
153 uniform.value = values;
154 uniform.num_values = 1;
155 uniform.location = -1;
156 uniforms_vec3.push_back(uniform);
159 void Effect::register_uniform_vec4(const std::string &key, const float *values)
161 Uniform<float> uniform;
163 uniform.value = values;
164 uniform.num_values = 1;
165 uniform.location = -1;
166 uniforms_vec4.push_back(uniform);
169 void Effect::register_uniform_float_array(const std::string &key, const float *values, size_t num_values)
171 Uniform<float> uniform;
173 uniform.value = values;
174 uniform.num_values = num_values;
175 uniform.location = -1;
176 uniforms_float_array.push_back(uniform);
179 void Effect::register_uniform_vec2_array(const std::string &key, const float *values, size_t num_values)
181 Uniform<float> uniform;
183 uniform.value = values;
184 uniform.num_values = num_values;
185 uniform.location = -1;
186 uniforms_vec2_array.push_back(uniform);
189 void Effect::register_uniform_vec3_array(const std::string &key, const float *values, size_t num_values)
191 Uniform<float> uniform;
193 uniform.value = values;
194 uniform.num_values = num_values;
195 uniform.location = -1;
196 uniforms_vec3_array.push_back(uniform);
199 void Effect::register_uniform_vec4_array(const std::string &key, const float *values, size_t num_values)
201 Uniform<float> uniform;
203 uniform.value = values;
204 uniform.num_values = num_values;
205 uniform.location = -1;
206 uniforms_vec4_array.push_back(uniform);
209 void Effect::register_uniform_mat3(const std::string &key, const Matrix3d *matrix)
211 Uniform<Matrix3d> uniform;
213 uniform.value = matrix;
214 uniform.num_values = 1;
215 uniform.location = -1;
216 uniforms_mat3.push_back(uniform);