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.
render::update(false);
// Redraw is slower, as a compromise it is done at FPS = UPS / 2
auto targetFps = options::Options.TargetUps / 2.0f;
targetFps = max(targetFps, 60.0f); // at least 60
// Frame time at 60 FPS = 16.(6) ms
auto targetTime = 1000.0f / targetFps;
frameTime += dtMilliSec;

View File

@ -224,12 +224,8 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
pb::toggle_demo();
else
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;
TargetFrameTime = max(TargetFrameTime, 1);
float TargetFrameTime = 1000.0f / options::Options.TargetUps;
DWORD someTimeCounter = 300u, prevTime = 0u, frameStart = timeGetTime();
float sleepRemainder = 0, frameDuration = TargetFrameTime;
while (true)