From 9a984056deefdc47c117e1df83135c22df017247 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Sun, 11 Jan 2026 09:55:15 +0800 Subject: [PATCH] fix stopwatch clock error --- BasaltPresenter/Plugins/Engine/DirectX11Engine/main.cpp | 1 - BasaltPresenter/Presenter/stopwatch.cpp | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/BasaltPresenter/Plugins/Engine/DirectX11Engine/main.cpp b/BasaltPresenter/Plugins/Engine/DirectX11Engine/main.cpp index b53b29e..951757c 100644 --- a/BasaltPresenter/Plugins/Engine/DirectX11Engine/main.cpp +++ b/BasaltPresenter/Plugins/Engine/DirectX11Engine/main.cpp @@ -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"); \ } diff --git a/BasaltPresenter/Presenter/stopwatch.cpp b/BasaltPresenter/Presenter/stopwatch.cpp index 34da384..55dc9df 100644 --- a/BasaltPresenter/Presenter/stopwatch.cpp +++ b/BasaltPresenter/Presenter/stopwatch.cpp @@ -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(stop_point - this->start_point); auto frame_time = static_cast(time_diff.count()) / this->interval; auto fps = 1000.0 / frame_time;