- glActiveTexture(GL_TEXTURE0);
- check_error();
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, base_mipmap_level);
- check_error();
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, base_mipmap_level);
- check_error();
+bool BlurEffect::set_int(const string &key, int value) {
+ if (key == "num_taps") {
+ if (value < 2 || value % 2 != 0) {
+ return false;
+ }
+ num_taps = value;
+ update_radius();
+ return true;
+ }
+ return false;
+}
+
+SingleBlurPassEffect::SingleBlurPassEffect(BlurEffect *parent)
+ : parent(parent),
+ num_taps(16),
+ radius(3.0f),
+ direction(HORIZONTAL),
+ width(1280),
+ height(720),
+ uniform_samples(NULL)
+{
+ register_float("radius", &radius);
+ register_int("direction", (int *)&direction);
+ register_int("width", &width);
+ register_int("height", &height);
+ register_int("virtual_width", &virtual_width);
+ register_int("virtual_height", &virtual_height);
+ register_int("num_taps", &num_taps);
+}
+
+SingleBlurPassEffect::~SingleBlurPassEffect()
+{
+ delete[] uniform_samples;
+}
+
+string SingleBlurPassEffect::output_fragment_shader()
+{
+ char buf[256];
+ sprintf(buf, "#define DIRECTION_VERTICAL %d\n#define NUM_TAPS %d\n",
+ (direction == VERTICAL), num_taps);
+ uniform_samples = new float[2 * (num_taps / 2 + 1)];
+ register_uniform_vec2_array("samples", uniform_samples, num_taps / 2 + 1);
+ return buf + read_file("blur_effect.frag");
+}
+
+void SingleBlurPassEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num)
+{
+ Effect::set_gl_state(glsl_program_num, prefix, sampler_num);