mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-31 19:51:45 +02:00
Stricter frame rate limiting
This commit is contained in:
committed by
Simon Robertshaw
parent
3e1ff2094c
commit
aa3f475edc
13
src/main.c
13
src/main.c
@@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user