Fixed another FPS issue

This commit is contained in:
Grayson Riffe (Desktop) 2021-09-08 02:21:15 -05:00
parent 2d3b3653ff
commit 70318b28fd

View File

@ -278,11 +278,10 @@ namespace nf {
m_renderer->doFrame(m_currentState->getCamera(), m_deltaTime); m_renderer->doFrame(m_currentState->getCamera(), m_deltaTime);
if (m_stateChange) if (m_stateChange)
doStateChange(); doStateChange();
}
m_fpsClock2 = std::chrono::steady_clock::now(); m_fpsClock2 = std::chrono::steady_clock::now();
m_fpsDuration = m_fpsClock2 - m_fpsClock1; m_fpsDuration = m_fpsClock2 - m_fpsClock1;
if (m_fpsDuration.count() >= 0.2) { if (m_fpsDuration.count() >= 0.2) {
m_FPS = (int)(1.0 / m_deltaTime); m_FPS = (int)std::round(1.0 / m_deltaTime);
static int i = 0; static int i = 0;
i++; i++;
if (i % 5 == 0) if (i % 5 == 0)
@ -290,6 +289,7 @@ namespace nf {
m_fpsClock1 = std::chrono::steady_clock::now(); m_fpsClock1 = std::chrono::steady_clock::now();
} }
} }
}
m_currentState->onExit(); m_currentState->onExit();
m_currentState->cleanup(); m_currentState->cleanup();
delete m_renderer; delete m_renderer;