1
0

fix stopwatch clock error

This commit is contained in:
2026-01-11 09:55:15 +08:00
parent 2e785a0e83
commit 9a984056de
2 changed files with 2 additions and 3 deletions

View File

@@ -16,7 +16,6 @@
using Microsoft::WRL::ComPtr;
#define DXCHK(condition) \
if (FAILED(condition)) { \
std::println("bad DirectX calling with code {}", condition); \
throw std::runtime_error("bad DirectX calling"); \
}

View File

@@ -3,7 +3,7 @@
namespace basalt::presenter::stopwatch {
Stopwatch::Stopwatch(size_t interval) : start_point(std::chrono::high_resolution_clock::now()), interval(interval), counter(0) {}
Stopwatch::Stopwatch(size_t interval) : start_point(std::chrono::steady_clock::now()), interval(interval), counter(0) {}
Stopwatch::~Stopwatch() {}
@@ -15,7 +15,7 @@ namespace basalt::presenter::stopwatch {
this->counter = 0;
// 记下当前时刻计算帧时间和FPS
auto stop_point = std::chrono::high_resolution_clock::now();
auto stop_point = std::chrono::steady_clock::now();
auto time_diff = std::chrono::duration_cast<std::chrono::milliseconds>(stop_point - this->start_point);
auto frame_time = static_cast<double>(time_diff.count()) / this->interval;
auto fps = 1000.0 / frame_time;