Stricter frame rate limiting

This commit is contained in:
jacksonmj
2011-04-22 04:57:07 +08:00
committed by Simon Robertshaw
parent 3e1ff2094c
commit aa3f475edc

View File

@@ -4267,16 +4267,21 @@ int main(int argc, char *argv[])
FPS++;
currentTime = SDL_GetTicks();
elapsedTime = currentTime-pastFPS;
if ((FPS>2 || elapsedTime>1000*2/limitFPS) && elapsedTime && FPS*1000/elapsedTime>limitFPS)
{
while (FPS*1000/elapsedTime>limitFPS)
{
SDL_Delay(1);
currentTime = SDL_GetTicks();
elapsedTime = currentTime-pastFPS;
}
}
if (elapsedTime>=1000)
{
FPSB = FPS;
FPS = 0;
pastFPS = currentTime;
}
else if (elapsedTime>20 && FPS*1000/elapsedTime>limitFPS)
{
SDL_Delay(5);
}
if (hud_enable)
{