From ff1e09b1b7086123fbaf7c9219d1784838b776ea Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Thu, 14 Aug 2008 16:12:36 -0300 Subject: [PATCH] Rewrite this one later. --- movie.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/movie.c b/movie.c index b2d85e3..448341a 100644 --- a/movie.c +++ b/movie.c @@ -18,7 +18,7 @@ #define WIDTH 800 #define HEIGHT 600 -#define FPS (200) +#define FPS (25) #define FRAME_INTERVAL (1000/FPS) #include @@ -114,19 +114,22 @@ ReadPoints (char *filename) void ShowPoint (SDL_Surface *screen, SDL_Surface *image, SDL_Rect center, double scale) { - center.x = (center.x - WIDTH/2) * scale; - center.y = (center.y - HEIGHT/2) * scale; + center.x = (center.x * scale) - WIDTH/2; + center.y = (center.y * scale) - HEIGHT/2; center.w = WIDTH; center.h = HEIGHT; SDL_BlitSurface (image, ¢er, screen, NULL); SDL_UpdateRect (screen, 0, 0, 0, 0); } +#define SCALE 2.0 + int main (int argc, char **argv) { SDL_Surface *screen; SDL_Surface *image; + SDL_Surface *scaled_image; SDL_Rect rect; SDL_Event event; Uint32 last, now, deslast, start; @@ -135,6 +138,7 @@ main (int argc, char **argv) SDL_Init (SDL_INIT_VIDEO | SDL_INIT_TIMER); screen = SDL_SetVideoMode (800, 600, 32, SDL_HWSURFACE | SDL_DOUBLEBUF); image = IMG_Load ("/home/cascardo/fotos/debconf.jpg"); + scaled_image = CairoScale (image, SCALE); start = deslast = last = SDL_GetTicks (); desl = des = i = 0; while (1) @@ -146,21 +150,25 @@ main (int argc, char **argv) } now = SDL_GetTicks (); /* skip */ - if (now > deslast + 1000) - { - printf ("%f %f\n", (double) (now - start) / (double) des, (double) (now - deslast) / (double) (des - desl)); - desl = des; - deslast = now; - } while (now > last + FRAME_INTERVAL) { last += FRAME_INTERVAL; i++; } + last = now; + if (now > deslast + 1000) + { + printf ("%f %f %d\n", (double) des / (double) (now - start) * 1000, (double) (des - desl) / (double) (now - deslast) * 1000, i - des); + desl = des; + deslast = now; + } if (i > points->len) + { + des -= i; i = 0; + } rect = g_array_index (points, SDL_Rect, i); - ShowPoint (screen, image, rect, 1.0); + ShowPoint (screen, scaled_image, rect, SCALE); SDL_Delay (FRAME_INTERVAL - (now - last)); i++; des++; -- 2.20.1