Added some time functions.

This commit is contained in:
2021-04-27 07:26:19 -07:00
parent e323cf2721
commit 96db74a546
10 changed files with 43 additions and 16 deletions

View File

@ -21,6 +21,7 @@ int32_t main() {
// Load GLAD
glfwMakeContextCurrent(window);
glfwSwapInterval(0);
gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
// Setup window listeners
@ -46,12 +47,21 @@ int32_t main() {
// Update the window title.
glfwSetWindowTitle(window, GAME_STATE.name);
// Main Render Loop
while(!glfwWindowShouldClose(window)) {
if(!gameUpdate()) break;
double time = 0;
glfwSwapBuffers(window);
// Main Render Loop
while(!glfwWindowShouldClose(window)) {
glfwPollEvents();
// Determine the delta.
double newTime = glfwGetTime();
float fDelta = (float)(newTime - time);
time = newTime;
// Tick the engine.
if(!gameUpdate(fDelta)) break;
glfwSwapBuffers(window);
sleep(0);
}
// Game has finished running, cleanup.