Replaced window close parameter with mutable flag.
Replaced the GLFW_SHOULD_CLOSE window parameter with the
glfwWindowShouldClose and glfwSetWindowShouldClose functions, allowing
the setting of the close flag from any point in the program.
diff --git a/examples/heightmap.c b/examples/heightmap.c
index 352d0e3..3e141b9 100644
--- a/examples/heightmap.c
+++ b/examples/heightmap.c
@@ -477,27 +477,13 @@
* GLFW callback functions
*********************************************************************/
-/* The program runs as long as this is GL_TRUE
- */
-static GLboolean running = GL_TRUE;
-
-/* GLFW Window management functions */
-static int window_close_callback(GLFWwindow* window)
-{
- running = GL_FALSE;
-
- /* Disallow window closing
- * The window will be closed when the main loop terminates */
- return 0;
-}
-
static void key_callback(GLFWwindow* window, int key, int action)
{
switch(key)
{
case GLFW_KEY_ESCAPE:
/* Exit program on Escape */
- running = GL_FALSE;
+ glfwSetWindowShouldClose(window, GL_TRUE);
break;
}
}
@@ -599,7 +585,6 @@
}
/* Register events callback */
- glfwSetWindowCloseCallback(window, window_close_callback);
glfwSetKeyCallback(window, key_callback);
glfwMakeContextCurrent(window);
@@ -661,7 +646,7 @@
iter = 0;
dt = last_update_time = glfwGetTime();
- while (running)
+ while (!glfwWindowShouldClose(window))
{
++frame;
/* render the next frame */