[SDL] How calculate the frame per seconds

Simon Ejsing simon at esoft.dk
Tue May 18 06:33:00 PDT 2004


On Tuesday 18 May 2004 15:24, NighTiger wrote:
> 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

	That's the msec difference, do this to get FPS:

		msec = SDL_GetTicks() - frameStart;
		if(msec > 0)
			fps = 1000.0 / (double) msec;


-- 
Simon Ejsing, Systemudvikler
esoft ApS, http://www.esoft.dk
Skibhusvej 52C, DK-5000 Odense C.
Tlf: 70 222 466, Fax: 63 122 466




More information about the SDL mailing list