[SDL] Capping the framerate? (not noob)

Torsten Giebl wizard at syntheticsw.com
Fri Aug 31 22:00:19 PDT 2007


Hello !


> ... that I can put in main() and will affect the whole program?
>
> Yes? No? Didn't think so. So what's the closest approach?
>
> Thanks in advance for any help provided!


?!?!?!


Sorry i don't see where the problem is.
I never used Lua, but i can image 3 cases :

1. You can call SDL functions directly from Lua.
Then do something like in Lua of course :

At the start of your main loop :

Uint32 startticks;
startticks = SDL_GetTicks ();

At the end :

Uint32 endticks = startticks + (1000/60);
SDL_Delay (therestofyourframetime);

2. You can call C functions from Lua :

Then put the stuff from 1 into two C functions.

3. You can only modify variables and arrays
from Lua, then put it into the main loop of your c code
at the start and end of it.


It affects all your code, but this is something
you normally want, when you have a frame limiter.


CU



More information about the SDL mailing list