]> git.sesse.net Git - movit/blobdiff - main.cpp
Make Input an abstract base class, and move the current functionality into FlatInput...
[movit] / main.cpp
index 869371626882eb506cf4cd9f617de4f9c17fb977..4fbcdf39d8e5ee3ff6cc8447f2db860ff409f907 100644 (file)
--- a/main.cpp
+++ b/main.cpp
 #include "util.h"
 #include "widgets.h"
 
+#include "flat_input.h"
+#include "lift_gamma_gain_effect.h"
+#include "saturation_effect.h"
+#include "diffusion_effect.h"
+
 unsigned char result[WIDTH * HEIGHT * 4];
 
 float lift_theta = 0.0f, lift_rad = 0.0f, lift_v = 0.0f;
@@ -164,20 +169,23 @@ int main(int argc, char **argv)
        inout_format.color_space = COLORSPACE_sRGB;
        inout_format.gamma_curve = GAMMA_sRGB;
 
-       Input *input = chain.add_input(inout_format);
-       Effect *lift_gamma_gain_effect = chain.add_effect(EFFECT_LIFT_GAMMA_GAIN);
-       Effect *saturation_effect = chain.add_effect(EFFECT_SATURATION);
-       Effect *diffusion_effect = chain.add_effect(EFFECT_DIFFUSION);
-       //Effect *vignette_effect = chain.add_effect(EFFECT_VIGNETTE);
-       //Effect *sandbox_effect = chain.add_effect(EFFECT_SANDBOX);
+       FlatInput *input = new FlatInput(inout_format, WIDTH, HEIGHT);
+       chain.add_input(input);
+       Effect *lift_gamma_gain_effect = chain.add_effect(new LiftGammaGainEffect());
+       Effect *saturation_effect = chain.add_effect(new SaturationEffect());
+       Effect *diffusion_effect = chain.add_effect(new DiffusionEffect());
+       //Effect *vignette_effect = chain.add_effect(new VignetteEffect());
+       //Effect *sandbox_effect = chain.add_effect(new SandboxEffect());
        //sandbox_effect->set_float("parm", 42.0f);
-       //chain.add_effect(EFFECT_MIRROR);
+       //chain.add_effect(new MirrorEffect());
        chain.add_output(inout_format);
        chain.finalize();
 
-       // generate a PDO to hold the data we read back with glReadPixels()
-       // (Intel/DRI goes into a slow path if we don't read to PDO)
-       glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 1);
+       // generate a PBO to hold the data we read back with glReadPixels()
+       // (Intel/DRI goes into a slow path if we don't read to PBO)
+       GLuint pbo;
+       glGenBuffers(1, &pbo);
+       glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, pbo);
        glBufferData(GL_PIXEL_PACK_BUFFER_ARB, WIDTH * HEIGHT * 4, NULL, GL_STREAM_READ);
 
        make_hsv_wheel_texture();
@@ -220,7 +228,7 @@ int main(int argc, char **argv)
                input->set_pixel_data(src_img);
                chain.render_to_screen();
                
-               glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 1);
+               glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, pbo);
                check_error();
                glReadPixels(0, 0, WIDTH, HEIGHT, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, BUFFER_OFFSET(0));
                check_error();
@@ -242,7 +250,7 @@ int main(int argc, char **argv)
                SDL_GL_SwapBuffers();
                check_error();
 
-               glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 1);
+               glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, pbo);
                check_error();
                unsigned char *screenbuf = (unsigned char *)glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY);
                check_error();