[SDL] Re: Simulation timer with thread
David Olofson
david.olofson at reologica.se
Wed Jan 23 09:00:01 PST 2002
On Tuesday 22 January 2002 21:43, Timo K Suoranta wrote:
[...]
> Now the actual question is that how should I synchronize the physics
> simulation with rendering? I do not want to slow down the physics
> simulation if the rendering is going too slow, but I am sure something
> could be done to improve the synchronization. Any ideas?
Kobo Deluxe does one of three things, depending on the control/rendering
frame rate ratio:
1. Control frame rate > rendering frame rate:
The control system is called several times per
rendered frame.
2. Control frame rate == rendering frame rate:
The control system is called once for each
rendered frame.
3. Control frame rate < rendering frame rate:
Several frames are rendered for each control
system frame.
Kobo Deluxe does not sleep, but just runs constantly, trying to pump out
the maximum FPS - but that doesn't really matter. It would work just as
well if an SDL_Delay(10) was inserted somewhere in the loop. (On targets
with retrace sync, it would *possibly* run slower, while on systems
without retrace sync, it *might* run smoother as a result of behaving
nicer in the eyes of the OS scheduler.)
Now, unless the rendering code does some form of interpolation between
the last two frames generated by the control system (as Kobo Deluxe does,
in order to get the smoothest possible animation), there's obviously no
point in rendering several video frames per control system frame in case
3. Just go to sleep (SDL_Delay()), or do something else.
//David Olofson --- Programmer, Reologica Instruments AB
.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
`----------------------------> http://www.linuxdj.com/maia -'
.- David Olofson -------------------------------------------.
| Audio Hacker - Open Source Advocate - Singer - Songwriter |
`-------------------------------------> http://olofson.net -'
More information about the SDL
mailing list