1
0
Fork 0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2024-11-24 18:00:18 +01:00

Improved TargetUps comments.

This commit is contained in:
Muzychenko Andrey 2022-01-17 09:54:28 +03:00
parent 4f8dd98135
commit b10fefd5af
2 changed files with 2 additions and 6 deletions

View file

@ -270,10 +270,10 @@ void pb::frame(float dtMilliSec)
// Retained render prevents frame skip. The next best thing - complete refresh at fixed rate. // Retained render prevents frame skip. The next best thing - complete refresh at fixed rate.
render::update(false); render::update(false);
// Redraw is slower, as a compromise it is done at FPS = UPS / 2
auto targetFps = options::Options.TargetUps / 2.0f; auto targetFps = options::Options.TargetUps / 2.0f;
targetFps = max(targetFps, 60.0f); // at least 60 targetFps = max(targetFps, 60.0f); // at least 60
// Frame time at 60 FPS = 16.(6) ms
auto targetTime = 1000.0f / targetFps; auto targetTime = 1000.0f / targetFps;
frameTime += dtMilliSec; frameTime += dtMilliSec;

View file

@ -225,11 +225,7 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
else else
pb::replay_level(0); pb::replay_level(0);
// To have a smooth display, Updates Per Sec (UPS) should be fps*2.
// Defaulted to 125 UPS, to leave some time for rendering.
float TargetFrameTime = 1000.0f / options::Options.TargetUps; float TargetFrameTime = 1000.0f / options::Options.TargetUps;
TargetFrameTime = max(TargetFrameTime, 1);
DWORD someTimeCounter = 300u, prevTime = 0u, frameStart = timeGetTime(); DWORD someTimeCounter = 300u, prevTime = 0u, frameStart = timeGetTime();
float sleepRemainder = 0, frameDuration = TargetFrameTime; float sleepRemainder = 0, frameDuration = TargetFrameTime;
while (true) while (true)