[SDL] FPS Counter?

QXY qxyka at freemail.hu
Thu Sep 14 13:11:01 PDT 2006


No need to divide ot sth...

int fps = 0; int fpsTimer = 0; char *fpsText = new char[ 10 ];

bool running = true; do {

// handle input

int now = SDL_GetTicks();
if ( now > fpsTimer + 1000 ) // count fps in 1 sec (1000 ms)
{
  sprintf( fpsText, "%d FPS", fps ); fpsTimer = now; fps = 0;
}

// draw goes here
// blit fps text

SDL_Flip( display ); fps++;

} while ( running );

--

qXy






More information about the SDL mailing list