Skip to content

Commit 53c9961

Browse files
committed
fix: fix fps counter being wrong
1 parent 3032a37 commit 53c9961

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/executables/game/application.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,13 @@ void Application::run() {
177177

178178
#if !defined(NDEBUG)
179179
auto start_time = SDL_GetPerformanceCounter();
180+
180181
const auto update_time = SDL_GetPerformanceFrequency() / 2; //0.5 s
182+
181183
const auto count_per_s = static_cast<double>(SDL_GetPerformanceFrequency());
184+
182185
u64 frame_counter = 0;
183-
m_debug = std::make_unique<helper::DebugInfo>(start_time, update_time, count_per_s, frame_counter);
186+
m_debug = std::make_unique<helper::DebugInfo>(start_time, frame_counter, update_time, count_per_s);
184187
#endif
185188
using namespace std::chrono_literals;
186189

@@ -221,11 +224,12 @@ void Application::main_loop() {
221224
const Uint64 current_time = SDL_GetPerformanceCounter();
222225

223226
if (current_time - m_debug->m_start_time >= m_debug->update_time()) {
224-
//TODO: debug in emscripten
225227
const double elapsed = static_cast<double>(current_time - m_debug->m_start_time) / m_debug->count_per_s();
228+
226229
m_fps_text->set_text(
227230
*this, fmt::format("FPS: {:.2f}", static_cast<double>(m_debug->m_frame_counter) / elapsed)
228231
);
232+
229233
m_debug->m_start_time = current_time;
230234
m_debug->m_frame_counter = 0;
231235
}

0 commit comments

Comments
 (0)