fix stopwatch clock error
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user