feat: move fps and deltatime calculations in core engine

This commit is contained in:
2025-10-23 16:10:22 +02:00
parent ef498ba210
commit 7b9858cffa
5 changed files with 47 additions and 38 deletions

View File

@ -5,6 +5,8 @@
#include "engine/window/event.hpp"
#include "engine/renderer/wavefront.h"
#include "engine/time/timestep.h"
namespace Core {
Engine* Engine::s_instance = nullptr;
@ -21,10 +23,18 @@ void Engine::Run(std::unique_ptr<IApplication> app) {
m_window->Subscribe(this);
uint64_t now = SDL_GetPerformanceCounter();
m_elapsed = 0;
while (m_running) {
m_elapsed = now;
now = SDL_GetPerformanceCounter();
auto dt = Timestep::FromMilliseconds((float)((now - m_elapsed)*1000 / (float)SDL_GetPerformanceFrequency()));
m_window->ProcessEvents();
m_app->OnUpdate();
m_app->OnUpdate(dt);
m_renderer->Render();