From c331551e407fda9803522433dc8871fa6cc5f4ba Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Tue, 14 Aug 2012 18:05:13 +0200 Subject: use SDL_gfx for framerate adjustment --- effect-pad.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'effect-pad.c') diff --git a/effect-pad.c b/effect-pad.c index 0911701..b942bdc 100644 --- a/effect-pad.c +++ b/effect-pad.c @@ -5,6 +5,7 @@ #include #include +#include //#define EFFECT_FIRE_COLORKEYED @@ -33,6 +34,7 @@ #define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 480 +#define FRAMERATE 20 /* Hz */ static SDL_Surface *screen; @@ -257,8 +259,10 @@ process_events(void) int main(int argc, char **argv) { - SDL_Surface *fire_surface; - SDL_Surface *image_surface; + FPSmanager fpsm; + + SDL_Surface *fire_surface; + SDL_Surface *image_surface; if (SDL_Init(SDL_INIT_VIDEO)) { SDL_ERROR("SDL_Init"); @@ -275,6 +279,9 @@ main(int argc, char **argv) return EXIT_FAILURE; } + SDL_initFramerate(&fpsm); + SDL_setFramerate(&fpsm, FRAMERATE); + image_surface = IMG_Load("image_1.jpg"); if (image_surface == NULL) { SDL_IMAGE_ERROR("IMG_Load"); @@ -296,7 +303,7 @@ main(int argc, char **argv) SDL_BlitSurface(fire_surface, NULL, screen, NULL); SDL_Flip(screen); - SDL_Delay(1000/20); + SDL_framerateDelay(&fpsm); } /* never reached */ -- cgit v1.2.3