I am making a C++ program with Opengl and GLFW for window and input handling.
The program is updated with the main loop by delta time which is calculated by subtracting new frame start time with old frame start time.
My problem is that when title bar is hold the whole program stops, but when it is released the delta time is as big as hold time.
I am also using chrono library for calculating passed time.
My code:
unsigned long second = std::chrono::seconds( 1 ) / precision;
frameStartTime = std::chrono::system_clock::now().time_since_epoch() / precision;
while ( running && !glfwWindowShouldClose( glfwWindow ) && !input::keyboard::isDown( GLFW_KEY_ESCAPE ) ) {
lastFrameTime = frameStartTime;
frameStartTime = std::chrono::system_clock::now().time_since_epoch() / precision;
deltaTime = float( frameStartTime - lastFrameTime ) / second;
glfwPollEvents();
mainScene->update( deltaTime );
input::clear();
mainScene->draw();
glfwSwapBuffers( glfwWindow );
countFps( deltaTime );
}
What am I doing wrong and how can I fix this issue?
Thanks.