From 1585c8b98145836e03dbdefe747e103fafe47a1a Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 5 Oct 2010 00:12:25 +0200 Subject: [PATCH] Added escape key quitting. --- tests/sharing.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/sharing.c b/tests/sharing.c index d2f47dbe..d290ef7a 100644 --- a/tests/sharing.c +++ b/tests/sharing.c @@ -35,6 +35,12 @@ #define WIDTH 400 #define HEIGHT 400 +static void key_callback(GLFWwindow window, int key, int action) +{ + if (action == GLFW_PRESS && key == GLFW_KEY_ESC) + glfwCloseWindow(window); +} + static GLFWwindow open_window(const char* title, GLFWwindow share) { GLFWwindow window; @@ -43,6 +49,7 @@ static GLFWwindow open_window(const char* title, GLFWwindow share) if (!window) return NULL; + glfwSetKeyCallback(window, key_callback); glfwSwapInterval(1); return window;