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.
This commit is contained in:
Camilla Berglund
2013-03-01 13:45:12 +01:00
parent f8f81e5754
commit 6fadf37bda
26 changed files with 155 additions and 215 deletions
+2 -15
View File
@@ -32,10 +32,6 @@
#define M_PI 3.141592654
#endif
/* The program exits when this is zero.
*/
static int running = 1;
/* If non-zero, the program exits after that many seconds
*/
static int autoexit = 0;
@@ -227,7 +223,7 @@ void key( GLFWwindow* window, int k, int action )
view_rotz += 5.0;
break;
case GLFW_KEY_ESCAPE:
running = 0;
glfwSetWindowShouldClose(window, GL_TRUE);
break;
case GLFW_KEY_UP:
view_rotx += 5.0;
@@ -267,14 +263,6 @@ void reshape( GLFWwindow* window, int width, int height )
}
/* close callback */
static int window_close_callback(GLFWwindow* window)
{
running = 0;
return GL_TRUE;
}
/* program & OpenGL initialization */
static void init(int argc, char *argv[])
{
@@ -349,7 +337,6 @@ int main(int argc, char *argv[])
}
// Set callback functions
glfwSetWindowCloseCallback(window, window_close_callback);
glfwSetWindowSizeCallback(window, reshape);
glfwSetKeyCallback(window, key);
@@ -363,7 +350,7 @@ int main(int argc, char *argv[])
init(argc, argv);
// Main loop
while( running )
while( !glfwWindowShouldClose(window) )
{
// Draw gears
draw();