]> git.sesse.net Git - movit/blobdiff - dither_effect.cpp
In ResampleEffect, optimize the bilinear weights on a global scale.
[movit] / dither_effect.cpp
index 14132bd43407bda72a7d2a8ca86f785bc9e1fab1..41ea9b432b80d3c94bf093a184f2632721dcbbcd 100644 (file)
@@ -1,4 +1,4 @@
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <stdio.h>
 #include <algorithm>
@@ -10,6 +10,8 @@
 
 using namespace std;
 
+namespace movit {
+
 namespace {
 
 // A simple LCG (linear congruental generator) random generator.
@@ -45,7 +47,7 @@ DitherEffect::~DitherEffect()
 string DitherEffect::output_fragment_shader()
 {
        char buf[256];
-       sprintf(buf, "#define NEED_EXPLICIT_ROUND %d\n", (movit_num_wrongly_rounded > 0));
+       sprintf(buf, "#define NEED_EXPLICIT_ROUND %d\n", (movit_num_wrongly_rounded > 0 && movit_shader_rounding_supported));
        return buf + read_file("dither_effect.frag");
 }
 
@@ -82,7 +84,7 @@ void DitherEffect::update_texture(GLuint glsl_program_num, const string &prefix,
        check_error();
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
        check_error();
-       glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE16F_ARB, texture_width, texture_height, 0, GL_LUMINANCE, GL_FLOAT, dither_noise);
+       glTexImage2D(GL_TEXTURE_2D, 0, GL_R16F, texture_width, texture_height, 0, GL_RED, GL_FLOAT, dither_noise);
        check_error();
 
        delete[] dither_noise;
@@ -109,7 +111,7 @@ void DitherEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, u
        check_error();
 
        set_uniform_int(glsl_program_num, prefix, "dither_tex", *sampler_num);
-       ++sampler_num;
+       ++*sampler_num;
 
        // In theory, we should adjust for the texel centers that have moved here as well,
        // but since we use GL_NEAREST and we don't really care a lot what texel we sample,
@@ -122,3 +124,5 @@ void DitherEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, u
        set_uniform_float(glsl_program_num, prefix, "round_fac", round_fac);
        set_uniform_float(glsl_program_num, prefix, "inv_round_fac", 1.0f / round_fac);
 }
+
+}  // namespace movit