mirror of
https://github.com/glfw/glfw.git
synced 2026-09-23 00:59:48 +00:00
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:
+2
-10
@@ -37,7 +37,6 @@
|
||||
|
||||
#define STEP_SIZE 0.1f
|
||||
|
||||
static GLboolean closed = GL_FALSE;
|
||||
static GLfloat gamma_value = 1.0f;
|
||||
|
||||
static void usage(void)
|
||||
@@ -61,12 +60,6 @@ static void error_callback(int error, const char* description)
|
||||
fprintf(stderr, "Error: %s\n", description);
|
||||
}
|
||||
|
||||
static int window_close_callback(GLFWwindow* window)
|
||||
{
|
||||
closed = GL_TRUE;
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
static void key_callback(GLFWwindow* window, int key, int action)
|
||||
{
|
||||
if (action != GLFW_PRESS)
|
||||
@@ -76,7 +69,7 @@ static void key_callback(GLFWwindow* window, int key, int action)
|
||||
{
|
||||
case GLFW_KEY_ESCAPE:
|
||||
{
|
||||
closed = GL_TRUE;
|
||||
glfwSetWindowShouldClose(window, GL_TRUE);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -157,7 +150,6 @@ int main(int argc, char** argv)
|
||||
glfwSwapInterval(1);
|
||||
|
||||
glfwSetKeyCallback(window, key_callback);
|
||||
glfwSetWindowCloseCallback(window, window_close_callback);
|
||||
glfwSetWindowSizeCallback(window, size_callback);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
@@ -166,7 +158,7 @@ int main(int argc, char** argv)
|
||||
|
||||
glClearColor(0.5f, 0.5f, 0.5f, 0);
|
||||
|
||||
while (!closed)
|
||||
while (!glfwWindowShouldClose(window))
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user