X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=demo.cpp;h=2243f2dd702b90419ef491963636c6508c76b669;hp=0cc3c48a4fedac0375ca12736be807d14cc3e752;hb=34f5f331bd3b643949ccbb0c3488af2823634d59;hpb=af39090a8902411ffc0c89f296a0f8bde9229f60 diff --git a/demo.cpp b/demo.cpp index 0cc3c48..2243f2d 100644 --- a/demo.cpp +++ b/demo.cpp @@ -18,6 +18,7 @@ #include #include +#include "init.h" #include "effect.h" #include "effect_chain.h" #include "util.h" @@ -144,7 +145,7 @@ void write_ppm(const char *filename, unsigned char *screenbuf) int main(int argc, char **argv) { - int quit = 0; + bool quit = false; SDL_Init(SDL_INIT_EVERYTHING); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); @@ -152,14 +153,16 @@ 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(); + 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); EffectChain chain(WIDTH, HEIGHT); + glViewport(0, 0, WIDTH, HEIGHT); ImageFormat inout_format; inout_format.color_space = COLORSPACE_sRGB; @@ -186,7 +189,8 @@ int main(int argc, char **argv) make_hsv_wheel_texture(); - int frame = 0, screenshot = 0; + int frame = 0; + bool screenshot = false; #if _POSIX_C_SOURCE >= 199309L struct timespec start, now; clock_gettime(CLOCK_MONOTONIC, &start); @@ -199,11 +203,11 @@ int main(int argc, char **argv) SDL_Event event; while (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT) { - quit = 1; + quit = true; } else if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE) { - quit = 1; + quit = true; } else if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_F1) { - screenshot = 1; + screenshot = true; } else if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_LEFT) { mouse(event.button.x, event.button.y); } else if (event.type == SDL_MOUSEMOTION && (event.motion.state & SDL_BUTTON(1))) { @@ -255,7 +259,7 @@ int main(int argc, char **argv) sprintf(filename, "frame%05d.ppm", frame); write_ppm(filename, screenbuf); printf("Screenshot: %s\n", filename); - screenshot = 0; + screenshot = false; } glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB); check_error();