[SDL] framerate counter

William Kendrick nbs at sonic.net
Wed Apr 4 03:00:35 PDT 2001


> 
> Hi there!
> 
> I've tried to make a framerate counter as wel as a framerate limiter (so the 
> game doesn't run faster than say, 50fps), but i've failed in doing so. I was 
> wondering if anyone has already done this before, and would care to share the 
> source of it with me.

I usually find out what time it is at the beginning of my loop
(gettimeofday()), then what time it is at the end of my loop.

If it's been less than 1000 / fps milliseconds, then I sleep
(SDL_Delay()) the difference.

-bill!



More information about the SDL mailing list