[SDL] How calculate the frame per seconds

Will McGugan will at willmcgugan.com
Tue May 18 06:32:05 PDT 2004


All you are calculating there is the time per frame. You want to find how
many times you can do that per second. So fps should be 1.f / (
(float)(newtime - oldtime) / 1000.f ). Although you would be better of
taking a sample over a number of frames..


Will McGugan

> -----Original Message-----
> From: sdl-bounces+will=willmcgugan.com at libsdl.org
> [mailto:sdl-bounces+will=willmcgugan.com at libsdl.org]On Behalf Of
> NighTiger
> Sent: 18 May 2004 14:25
> To: SDL
> Subject: [SDL] How calculate the frame per seconds
>
>
> I have write this code:
>
> newtime = 0;
> while ( !quit )
> {
> oldtime = newtime;
> newtime = SDL_GetTicks();
> quit = Keyboard();
> DrawObject();
> fps = (newtime - oldtime);
> printf("%i\n", fps);
> }
>
> it's wrong?
> tnx
>
>
>
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
>






More information about the SDL mailing list