This is my game engine's game loop.
Initialize();
Timer timer{};
while (window.IsRunning())
{
timer.Tick();
timer.Reset();
Update(timer.GetDeltaTime());
Render(timer.GetDeltaTime());
window.Update();
}
Cleanup();
These are my Timer class code.
Timer::Timer()
{
Reset();
m_DeltaTime = std::chrono::duration<float>(0.f);
}
void Timer::Reset()
{
m_StartTime = std::chrono::high_resolution_clock::now();
}
float Timer::GetDeltaTime() const
{
return m_DeltaTime.count();
}
void Timer::Tick()
{
m_DeltaTime = std::chrono::high_resolution_clock::now() - m_StartTime;
}
And I found that my deltaTime is zero! I have no idea why this is happening. Help
