Fixed invalid uses of glfwDestroyWindow.

This commit is contained in:
Camilla Berglund
2012-09-13 17:29:07 +02:00
parent 4408d2134c
commit 89018331f7
6 changed files with 71 additions and 46 deletions
+13 -4
View File
@@ -34,6 +34,8 @@
#include "getopt.h"
static GLboolean closed = GL_FALSE;
static void usage(void)
{
printf("Usage: clipboard [-h]\n");
@@ -45,6 +47,12 @@ static GLboolean control_is_down(GLFWwindow window)
glfwGetKey(window, GLFW_KEY_RIGHT_CONTROL);
}
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)
@@ -53,7 +61,7 @@ static void key_callback(GLFWwindow window, int key, int action)
switch (key)
{
case GLFW_KEY_ESCAPE:
glfwDestroyWindow(window);
closed = GL_TRUE;
break;
case GLFW_KEY_V:
@@ -80,7 +88,7 @@ static void key_callback(GLFWwindow window, int key, int action)
}
}
static void size_callback(GLFWwindow window, int width, int height)
static void window_size_callback(GLFWwindow window, int width, int height)
{
glViewport(0, 0, width, height);
}
@@ -130,7 +138,8 @@ int main(int argc, char** argv)
glfwSwapInterval(1);
glfwSetKeyCallback(key_callback);
glfwSetWindowSizeCallback(size_callback);
glfwSetWindowSizeCallback(window_size_callback);
glfwSetWindowCloseCallback(window_close_callback);
glMatrixMode(GL_PROJECTION);
glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f);
@@ -138,7 +147,7 @@ int main(int argc, char** argv)
glClearColor(0.5f, 0.5f, 0.5f, 0);
while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
while (!closed)
{
glClear(GL_COLOR_BUFFER_BIT);