annotate pytouhou/lib/glfw.pyx @ 720:cffb0f1531fc

ecl_vm: implemented spellcard QED: Ripple of 495 years
author Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
date Wed, 25 Sep 2019 16:59:21 +0200
parents 4fa0a8e7d941
children f953ae5b3732
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
636
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
1 # -*- encoding: utf-8 -*-
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
2 ##
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3 ## Copyright (C) 2016 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
4 ##
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
5 ## This program is free software; you can redistribute it and/or modify
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
6 ## it under the terms of the GNU General Public License as published
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
7 ## by the Free Software Foundation; version 3 only.
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
8 ##
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
9 ## This program is distributed in the hope that it will be useful,
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
12 ## GNU General Public License for more details.
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
13 ##
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
14
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
15 from .gui cimport SHOOT, BOMB, FOCUS, UP, DOWN, LEFT, RIGHT, SKIP
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
16
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
17 CLIENT_API = GLFW_CLIENT_API
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
18 OPENGL_PROFILE = GLFW_OPENGL_PROFILE
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
19 CONTEXT_VERSION_MAJOR = GLFW_CONTEXT_VERSION_MAJOR
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
20 CONTEXT_VERSION_MINOR = GLFW_CONTEXT_VERSION_MINOR
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
21 DEPTH_BITS = GLFW_DEPTH_BITS
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
22 ALPHA_BITS = GLFW_ALPHA_BITS
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
23 RESIZABLE = GLFW_RESIZABLE
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
24 DOUBLEBUFFER = GLFW_DOUBLEBUFFER
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
25
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
26 OPENGL_API = GLFW_OPENGL_API
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
27 OPENGL_ES_API = GLFW_OPENGL_ES_API
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
28 OPENGL_CORE_PROFILE = GLFW_OPENGL_CORE_PROFILE
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
29
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
30 cdef void error_callback(int a, const char* b):
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
31 print('GLFW error 0x%x: %s' % (a, b.decode('utf-8')))
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
32
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
33 cdef list _global_events = []
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
34
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
35 cdef void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods):
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
36 if action != GLFW_PRESS:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
37 return
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
38 if key == GLFW_KEY_ESCAPE:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
39 _global_events.append((gui.PAUSE, None))
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
40 elif key in (GLFW_KEY_P, GLFW_KEY_HOME):
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
41 _global_events.append((gui.SCREENSHOT, None))
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
42 elif key == GLFW_KEY_DOWN:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
43 _global_events.append((gui.DOWN, None))
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
44 elif key == GLFW_KEY_F11:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
45 _global_events.append((gui.FULLSCREEN, None))
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
46 elif key == GLFW_KEY_ENTER:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
47 if mods & GLFW_MOD_ALT:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
48 _global_events.append((gui.FULLSCREEN, None))
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
49
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
50 cdef void size_callback(GLFWwindow* window, int width, int height):
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
51 _global_events.append((gui.RESIZE, (width, height)))
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
52
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
53 cdef void close_callback(GLFWwindow* window):
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
54 _global_events.append((gui.EXIT, None))
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
55
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
56 cdef void init() except *:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
57 glfwSetErrorCallback(<GLFWerrorfun>error_callback)
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
58 ret = glfwInit()
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
59 if not ret:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
60 raise Exception('TODO')
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
61
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
62 cdef void terminate() nogil:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
63 glfwTerminate()
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
64
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
65 cdef void window_hint(int hint, int value) nogil:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
66 glfwWindowHint(hint, value)
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
67
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
68 cdef class Window:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
69 def __init__(self, int width, int height, str title, Monitor monitor=None, Window share=None):
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
70 cdef GLFWmonitor* c_monitor = NULL
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
71 cdef GLFWwindow* c_share = NULL
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
72 if monitor is not None:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
73 c_monitor = monitor.monitor
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
74 if share is not None:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
75 c_share = share.window
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
76 self.window = glfwCreateWindow(width, height, title.encode('utf-8'), c_monitor, c_share)
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
77 if self.window == NULL:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
78 raise Exception('TODO')
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
79 glfwSetFramebufferSizeCallback(self.window, <GLFWframebuffersizefun>size_callback)
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
80 glfwSetWindowCloseCallback(self.window, <GLFWwindowclosefun>close_callback)
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
81 glfwSetKeyCallback(self.window, <GLFWkeyfun>key_callback)
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
82
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
83 def __del__(self):
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
84 glfwDestroyWindow(self.window)
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
85
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
86 cdef void create_gl_context(self) except *:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
87 glfwMakeContextCurrent(self.window)
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
88
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
89 cdef void present(self) nogil:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
90 glfwSwapBuffers(self.window)
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
91
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
92 cdef void set_window_size(self, int width, int height) nogil:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
93 pass
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
94
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
95 cdef list get_events(self):
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
96 glfwPollEvents()
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
97 events = _global_events[:]
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
98 _global_events.clear()
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
99 return events
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
100
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
101 cdef void toggle_fullscreen(self) nogil:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
102 monitor = glfwGetWindowMonitor(self.window)
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
103 if monitor == NULL:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
104 monitor = glfwGetPrimaryMonitor()
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
105 else:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
106 monitor = NULL
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
107 # TODO: save the previous size.
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
108 glfwSetWindowMonitor(self.window, monitor, 0, 0, 640, 480, 60)
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
109
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
110 cdef int get_keystate(self) nogil:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
111 cdef int keystate = 0
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
112 if glfwGetKey(self.window, GLFW_KEY_Z):
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
113 keystate |= SHOOT
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
114 if glfwGetKey(self.window, GLFW_KEY_X):
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
115 keystate |= BOMB
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
116 if glfwGetKey(self.window, GLFW_KEY_LEFT_SHIFT):
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
117 keystate |= FOCUS
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
118 if glfwGetKey(self.window, GLFW_KEY_UP):
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
119 keystate |= UP
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
120 if glfwGetKey(self.window, GLFW_KEY_DOWN):
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
121 keystate |= DOWN
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
122 if glfwGetKey(self.window, GLFW_KEY_LEFT):
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
123 keystate |= LEFT
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
124 if glfwGetKey(self.window, GLFW_KEY_RIGHT):
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
125 keystate |= RIGHT
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
126 if glfwGetKey(self.window, GLFW_KEY_LEFT_CONTROL):
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
127 keystate |= SKIP
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
128 return keystate