]> git.sesse.net Git - movit/blobdiff - effect_chain.cpp
Fix R/B swapping in the SDL conversion.
[movit] / effect_chain.cpp
index 270eae6c4ce9bd7933c46f3f3ffae1ce4e4ac27b..7cc23ff1c1cbd98114f9d076ed20a52f00d4ee6a 100644 (file)
@@ -13,6 +13,7 @@
 #include "gamma_compression_effect.h"
 #include "lift_gamma_gain_effect.h"
 #include "colorspace_conversion_effect.h"
+#include "sandbox_effect.h"
 #include "saturation_effect.h"
 #include "mirror_effect.h"
 #include "vignette_effect.h"
@@ -42,6 +43,8 @@ Effect *instantiate_effect(EffectId effect)
                return new GammaCompressionEffect();
        case EFFECT_COLOR_SPACE_CONVERSION:
                return new ColorSpaceConversionEffect();
+       case EFFECT_SANDBOX:
+               return new SandboxEffect();
        case EFFECT_LIFT_GAMMA_GAIN:
                return new LiftGammaGainEffect();
        case EFFECT_SATURATION:
@@ -260,10 +263,7 @@ void EffectChain::finalize()
        check_error();
        glBufferData(GL_PIXEL_UNPACK_BUFFER_ARB, width * height * bytes_per_pixel, NULL, GL_STREAM_DRAW);
        check_error();
-
-       void *mapped_pbo = glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY);
-       memset(mapped_pbo, 0, width * height * bytes_per_pixel);
-       glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB);
+       glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
        check_error();
        
        glGenTextures(1, &source_image_num);
@@ -272,9 +272,7 @@ void EffectChain::finalize()
        check_error();
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        check_error();
-       glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, format, GL_UNSIGNED_BYTE, BUFFER_OFFSET(0));
-       check_error();
-       glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
+       glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, format, GL_UNSIGNED_BYTE, NULL);
        check_error();
 
        finalized = true;
@@ -303,6 +301,11 @@ void EffectChain::render_to_screen(unsigned char *src)
        check_error();
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
        check_error();
+
+       // Intel/Mesa seems to have a broken glGenerateMipmap() for non-FBO textures, so do it here.
+       glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, phases[0].input_needs_mipmaps ? GL_TRUE : GL_FALSE);
+       check_error();
+
        glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
        check_error();
 
@@ -336,8 +339,11 @@ void EffectChain::render_to_screen(unsigned char *src)
                        check_error();
                }
                if (phases[phase].input_needs_mipmaps) {
-                       glGenerateMipmap(GL_TEXTURE_2D);
-                       check_error();
+                       if (phase != 0) {
+                               // For phase 0, it's done further up.
+                               glGenerateMipmap(GL_TEXTURE_2D);
+                               check_error();
+                       }
                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
                        check_error();
                } else {