Fixed FPS timing issue
This commit is contained in:
parent
5bfcb1f163
commit
95426b9205
@ -112,25 +112,25 @@ namespace nf {
|
|||||||
void Application::startMainThread() {
|
void Application::startMainThread() {
|
||||||
createOpenGLContext();
|
createOpenGLContext();
|
||||||
while (m_running) {
|
while (m_running) {
|
||||||
m_fpsDuration = std::chrono::steady_clock::now() - m_frameClock;
|
m_deltaTime = m_fpsDuration.count();
|
||||||
if (m_fpsDuration.count() >= m_minFrametime) {
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
m_deltaTime = m_fpsDuration.count();
|
m_currentState->update();
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
m_currentState->render();
|
||||||
m_currentState->update();
|
SwapBuffers(m_hdc);
|
||||||
m_currentState->render();
|
m_frames++;
|
||||||
SwapBuffers(m_hdc);
|
|
||||||
m_frames++;
|
|
||||||
m_frameClock = std::chrono::steady_clock::now();
|
|
||||||
}
|
|
||||||
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() >= 1.0) {
|
if (m_fpsDuration.count() >= 1.0) {
|
||||||
m_fpsClock1 = std::chrono::steady_clock::now();
|
m_fpsClock1 = std::chrono::steady_clock::now();
|
||||||
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
|
|
||||||
m_FPS = m_frames;
|
m_FPS = m_frames;
|
||||||
m_frames = 0;
|
m_frames = 0;
|
||||||
Log((int)glGetError());
|
Log(m_FPS);
|
||||||
}
|
}
|
||||||
|
m_fpsDuration = std::chrono::steady_clock::now() - m_frameClock;
|
||||||
|
while (m_fpsDuration.count() < m_minFrametime) {
|
||||||
|
m_fpsDuration = std::chrono::steady_clock::now() - m_frameClock;
|
||||||
|
}
|
||||||
|
m_frameClock = std::chrono::steady_clock::now();
|
||||||
}
|
}
|
||||||
m_currentState->onExit();
|
m_currentState->onExit();
|
||||||
}
|
}
|
||||||
|
@ -16,15 +16,14 @@ Remember to use tasks (//TODO: )
|
|||||||
*Separate project
|
*Separate project
|
||||||
*Namespaced
|
*Namespaced
|
||||||
*Debug and log system
|
*Debug and log system
|
||||||
NatVis
|
*NatVis
|
||||||
Command line options
|
|
||||||
Video options
|
Video options
|
||||||
*Alt-Enter
|
*Alt-Enter
|
||||||
File IO functions
|
File IO functions
|
||||||
Options file (Executable directory)
|
Options file (Executable directory)
|
||||||
Input
|
Input
|
||||||
Audio
|
Audio
|
||||||
Game states
|
*Game states
|
||||||
Text rendering
|
Text rendering
|
||||||
UI elements
|
UI elements
|
||||||
Resource system and custom format
|
Resource system and custom format
|
||||||
|
Reference in New Issue
Block a user