mirror of
https://github.com/Boof2015/prism.git
synced 2026-08-18 19:44:16 +02:00
fix windows tui frame timing bug
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
#include "frame_pacing.h"
|
||||
|
||||
namespace Prism::Tui {
|
||||
|
||||
std::chrono::steady_clock::time_point advanceFrameDeadline(
|
||||
std::chrono::steady_clock::time_point currentDeadline,
|
||||
std::chrono::steady_clock::time_point renderedAt,
|
||||
std::chrono::steady_clock::duration frameInterval) {
|
||||
if (frameInterval <= std::chrono::steady_clock::duration::zero()) {
|
||||
return renderedAt;
|
||||
}
|
||||
|
||||
const auto elapsed = renderedAt - currentDeadline;
|
||||
const auto intervalsToAdvance = elapsed >= decltype(elapsed)::zero()
|
||||
? elapsed / frameInterval + 1
|
||||
: 1;
|
||||
return currentDeadline + frameInterval * intervalsToAdvance;
|
||||
}
|
||||
|
||||
} // namespace Prism::Tui
|
||||
Reference in New Issue
Block a user