commit a4663a1309d2830ecb31125501ecc9e3911f0b68
parent 5b396707c89bd95bc27f5eaeea57071985b1b13b
Author: Kyle Milz <kyle@0x30.net>
Date: Sun, 11 Dec 2016 12:46:52 -0700
src: hook up 'q' key
Diffstat:
3 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/gl_main.cc b/src/gl_main.cc
@@ -39,9 +39,9 @@ reshape_func(int width, int height)
}
void
-keyboard_func(unsigned char key, int x, int y)
+keyboard_func(GLFWwindow *window, int key, int scancode, int action, int mods)
{
- static_vu->keyboard_func(key, x, y);
+ static_vu->keyboard_func(window, key, scancode, action, mods);
}
void
@@ -233,11 +233,10 @@ main(int argc, char *argv[])
return 1;
}
- // glfwSetKeyCallback(window, key_callback);
+ glfwSetKeyCallback(window, keyboard_func);
// glutReshapeFunc(reshape_func);
// glutDisplayFunc(display);
- // glutKeyboardFunc(keyboard_func);
// glutSpecialFunc(special_func);
// glutMouseFunc(mouse_func);
// glutMotionFunc(motion_func);
diff --git a/src/gl_view.cc b/src/gl_view.cc
@@ -17,7 +17,6 @@
*/
#include "gl_view.h"
-#include <GLFW/glfw3.h>
extern "C" {
#include "trackball.h"
@@ -231,13 +230,13 @@ View::reshape_func(int width, int height)
#define STEP 1.05
void
-View::keyboard_func(unsigned char key, int x, int y)
+View::keyboard_func(GLFWwindow *window, int key, int scancode, int action, int mods)
{
switch (key)
{
case '\033':
- case 'q':
- exit (0);
+ case GLFW_KEY_Q:
+ glfwSetWindowShouldClose(window, 1);
break;
case ' ':
diff --git a/src/gl_view.h b/src/gl_view.h
@@ -4,6 +4,7 @@
#include "demo-common.h"
#include "gl_buffer.h"
#include "demo-glstate.h"
+#include <GLFW/glfw3.h>
class View {
public:
@@ -12,7 +13,7 @@ public:
void reset();
void reshape_func(int, int);
- void keyboard_func(unsigned char key, int x, int y);
+ void keyboard_func(GLFWwindow *, int, int, int, int);
void special_func(int key, int x, int y);
void mouse_func(int button, int state, int x, int y);
void motion_func(int x, int y);