[SDL] Framerate independence?
Jonathan B.
jon at number-none.com
Mon Feb 12 20:08:42 PST 2007
Oh wow. Please *do not* do it like this. This is a busy wait which
will attempt to eat 100% of your CPU doing nothing until the appropriate
time. It is really horrible for any multitasking OS.
It is much better to use SDL_Delay as mentioned on the usingtimers.html
page.
RCAF wrote:
> Hi!
>
> Look this page:
>
> http://www.libsdl.org/intro.en/usingtimers.html
>
> but I prefer to do it so:
>
> Uint32 t1, t2;
> int fps = 100;
> int done=1;
>
> while (!done)
> {
> t1 = SDL_GetTicks(); // Initial time
>
> // do something... input, game logic, drawing, ...
>
> do
> {
> t2 = SDL_GetTicks(); // Current time
> } while ((t2 - t1) <= 1000/fps);
> }
>
> Regards!
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
>
More information about the SDL
mailing list