[SDL] framerate counter
A. Umbach
marvin at dataway.ch
Thu Apr 5 07:14:19 PDT 2001
Timo K Suoranta <tksuoran at cc.helsinki.fi> schrieb am 05 Apr 2001:
> Any realtime simulation IMHO. It is best to have the simulation work at
> something like 35 - 400 simulation frames per second, and since current
> machine easily *can* handle 400 or even more sfps, why not? Performance
> counter in win32 gives sort of preciside time measurements AFAIK.
>
> > I'm not sure if a high-response (emphasis on fast response) system is
> > needed beyond 5ms (==5000 microseconds) for SDL... requirements beyond
>
> I am not looking for fast response. It just happens that I need to be
> able to measure things that can take less time than 1 ms. Computers
> keep getting faster and faster, and there is a chance that I can run
> some simulation 10000 times per seconds. And the simulation might need
> timing information. Which is provided by performance counter (is it
> available in linux in any form?). So I don't see why SDL couldn't let
> me use as precise timing info as possible.
>
> I use floating point data as well. Mostly doubles though.
I might make sense to run your simulation n times per second, but you don't
need to *display* it at more than 60 FPS. So you can do:
while(1) {
thistime = SDL_GetTicks();
while(lasttime < thistime) {
lasttime += 1 / SIMULATION_RATE;
runSimulation(lasttime);
/* thistime = SDL_GetTicks(); */
}
displayResult(lasttime);
}
This way your simulation runs at a constant rate.
For even more exact results, update the thistime after every calculation.
Of course, if your computer can't keep up, you'll never see a frame.
- Andreas
--
Check out my 3D lightcycle game: http://www.gltron.org
More than 100'000 Downloads of the last version (0.59)
More information about the SDL
mailing list