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 -12
View File
@@ -33,8 +33,6 @@
#include <stdio.h>
#include <stdlib.h>
static GLboolean running = GL_TRUE;
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
@@ -57,7 +55,7 @@ static void window_key_callback(GLFWwindow* window, int key, int action)
case GLFW_KEY_ESCAPE:
{
printf("%0.3f: User pressed Escape\n", glfwGetTime());
running = GL_FALSE;
glfwSetWindowShouldClose(window, GL_TRUE);
break;
}
@@ -70,13 +68,6 @@ static void window_key_callback(GLFWwindow* window, int key, int action)
}
}
static int window_close_callback(GLFWwindow* window)
{
printf("%0.3f: User closed window\n", glfwGetTime());
running = GL_FALSE;
return GL_TRUE;
}
int main(void)
{
GLFWwindow* window;
@@ -100,9 +91,8 @@ int main(void)
glfwSetWindowFocusCallback(window, window_focus_callback);
glfwSetKeyCallback(window, window_key_callback);
glfwSetWindowCloseCallback(window, window_close_callback);
while (running)
while (!glfwWindowShouldClose(window))
{
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);