Added some time functions.
This commit is contained in:
@ -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.
|
||||
|
Reference in New Issue
Block a user