]> git.sesse.net Git - movit/blobdiff - demo.cpp
Revert all the changes in demo.cpp that were never supposed to be there in the last...
[movit] / demo.cpp
index 552380a9cf971ac984c43ebbf77708ea58bdefb2..5fec3fcee6008df87668a60253541f1083210dd8 100644 (file)
--- a/demo.cpp
+++ b/demo.cpp
 #include <vector>
 #include <map>
 
+#include <GL/glew.h>
+
 #include <SDL/SDL.h>
 #include <SDL/SDL_opengl.h>
 #include <SDL/SDL_image.h>
 
+#include "init.h"
 #include "effect.h"
 #include "effect_chain.h"
 #include "util.h"
-#include "opengl.h"
 #include "widgets.h"
 
 #include "flat_input.h"
@@ -152,20 +154,22 @@ int main(int argc, char **argv)
        SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
        SDL_SetVideoMode(WIDTH, HEIGHT, 0, SDL_OPENGL);
        SDL_WM_SetCaption("OpenGL window", NULL);
-       
-       // geez 
-       glPixelStorei(GL_PACK_ALIGNMENT, 1);
 
+       init_movit(".", MOVIT_DEBUG_ON);
+       printf("GPU texture subpixel precision: about %.1f bits\n",
+               log2(1.0f / movit_texel_subpixel_precision));
+       
        unsigned img_w, img_h;
-       unsigned char *src_img = load_image("blg_wheels_woman_1.jpg", &img_w, &img_h);
+       unsigned char *src_img = load_image(argc > 1 ? argv[1] : "blg_wheels_woman_1.jpg", &img_w, &img_h);
 
        EffectChain chain(WIDTH, HEIGHT);
+       glViewport(0, 0, WIDTH, HEIGHT);
 
        ImageFormat inout_format;
        inout_format.color_space = COLORSPACE_sRGB;
        inout_format.gamma_curve = GAMMA_sRGB;
 
-       FlatInput *input = new FlatInput(inout_format, FORMAT_BGRA, GL_UNSIGNED_BYTE, img_w, img_h);
+       FlatInput *input = new FlatInput(inout_format, FORMAT_BGRA_POSTMULTIPLIED_ALPHA, GL_UNSIGNED_BYTE, img_w, img_h);
        chain.add_input(input);
        Effect *lift_gamma_gain_effect = chain.add_effect(new LiftGammaGainEffect());
        Effect *saturation_effect = chain.add_effect(new SaturationEffect());
@@ -174,7 +178,8 @@ int main(int argc, char **argv)
        //Effect *sandbox_effect = chain.add_effect(new SandboxEffect());
        //sandbox_effect->set_float("parm", 42.0f);
        //chain.add_effect(new MirrorEffect());
-       chain.add_output(inout_format);
+       chain.add_output(inout_format, OUTPUT_ALPHA_POSTMULTIPLIED);
+       chain.set_dither_bits(8);
        chain.finalize();
 
        // generate a PBO to hold the data we read back with glReadPixels()
@@ -219,8 +224,8 @@ int main(int argc, char **argv)
                //vignette_effect->set_float("inner_radius", inner_radius);
                //vignette_effect->set_vec2("center", (float[]){ 0.7f, 0.5f });
 
-               diffusion_effect->set_float("radius", blur_radius);
-               diffusion_effect->set_float("blurred_mix_amount", blurred_mix_amount);
+               CHECK(diffusion_effect->set_float("radius", blur_radius));
+               CHECK(diffusion_effect->set_float("blurred_mix_amount", blurred_mix_amount));
 
                input->set_pixel_data(src_img);
                chain.render_to_screen();