glfw 1.0.3 → 3.3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +161 -0
- data/.yardopts +6 -0
- data/Gemfile +2 -4
- data/README.md +29 -33
- data/Rakefile +6 -4
- data/ext/glfw/common.c +159 -0
- data/ext/glfw/cursor.c +34 -30
- data/ext/glfw/extconf.rb +7 -17
- data/ext/glfw/glfw.c +122 -377
- data/ext/glfw/glfw.h +46 -41
- data/ext/glfw/image.c +96 -64
- data/ext/glfw/joystick.c +169 -0
- data/ext/glfw/monitor.c +231 -155
- data/ext/glfw/stb_image.h +7656 -0
- data/ext/glfw/window.c +708 -576
- data/glfw.gemspec +10 -9
- data/lib/glfw.rb +4 -14
- data/lib/glfw/constants.rb +365 -0
- data/lib/glfw/stubs.rb +234 -0
- data/lib/glfw/stubs/cursor.rb +21 -0
- data/lib/glfw/stubs/gamepad_state.rb +30 -0
- data/lib/glfw/stubs/image.rb +39 -0
- data/lib/glfw/stubs/joystick.rb +125 -0
- data/lib/glfw/stubs/monitor.rb +115 -0
- data/lib/glfw/stubs/video_mode.rb +32 -0
- data/lib/glfw/stubs/window.rb +626 -0
- data/lib/glfw/version.rb +8 -1
- metadata +31 -35
- data/.travis.yml +0 -5
- data/Makefile +0 -267
- data/ext/glfw/common.h +0 -46
- data/ext/glfw/cursor.h +0 -14
- data/ext/glfw/glfw3.h +0 -4248
- data/ext/glfw/glfw3native.h +0 -456
- data/ext/glfw/image.h +0 -14
- data/ext/glfw/ming32/WINDOWS USERS PLACE libglf3.a HERE.txt b/data/ext/glfw/ming32/WINDOWS USERS PLACE libglf3.a → HERE.txt +0 -0
- data/ext/glfw/ming64/WINDOWS USERS PLACE libglf3.a HERE.txt b/data/ext/glfw/ming64/WINDOWS USERS PLACE libglf3.a → HERE.txt +0 -0
- data/ext/glfw/monitor.h +0 -29
- data/ext/glfw/video_mode.c +0 -60
- data/ext/glfw/video_mode.h +0 -21
- data/ext/glfw/vulkan.c +0 -48
- data/ext/glfw/vulkan.h +0 -16
- data/ext/glfw/window.h +0 -87
data/glfw.gemspec
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "glfw/version"
|
2
|
+
require_relative 'lib/glfw/version'
|
5
3
|
|
6
4
|
Gem::Specification.new do |spec|
|
7
5
|
spec.name = "glfw"
|
@@ -10,9 +8,9 @@ Gem::Specification.new do |spec|
|
|
10
8
|
spec.email = ["efreed09@gmail.com"]
|
11
9
|
|
12
10
|
spec.summary = %q{GLFW is an Open Source, multi-platform library for OpenGL, OpenGL ES and Vulkan development on the desktop. It provides a simple API for creating windows, contexts and surfaces, receiving input and events.}
|
13
|
-
spec.description = %q{This is a high-performance Ruby C-extension for the excellent
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
11
|
+
spec.description = %q{This is a high-performance Ruby C-extension for the excellent GLFW3 library.}
|
12
|
+
spec.homepage = 'https://github.com/ForeverZer0/glfw'
|
13
|
+
spec.license = 'MIT'
|
16
14
|
|
17
15
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
18
16
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
@@ -22,8 +20,11 @@ Gem::Specification.new do |spec|
|
|
22
20
|
spec.extensions = ["ext/glfw/extconf.rb"]
|
23
21
|
|
24
22
|
spec.required_ruby_version = '>= 2.0.0'
|
23
|
+
spec.requirements << 'libglfw, v.3.3'
|
24
|
+
spec.metadata['msys2_mingw_dependencies'] = 'glfw'
|
25
|
+
spec.rdoc_options << '--exclude' << 'ext/*'
|
25
26
|
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
27
|
+
spec.add_development_dependency 'yard', '~> 0.9'
|
28
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
29
|
+
spec.add_development_dependency 'rake-compiler', '~> 1.1'
|
29
30
|
end
|
data/lib/glfw.rb
CHANGED
@@ -1,14 +1,4 @@
|
|
1
|
-
require_relative
|
2
|
-
require_relative
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
# window.make_current
|
7
|
-
|
8
|
-
# until window.closing?
|
9
|
-
# GLFW.poll_events
|
10
|
-
# window.swap_buffers
|
11
|
-
# end
|
12
|
-
# end
|
13
|
-
|
14
|
-
# GLFW.terminate
|
1
|
+
require_relative 'glfw/version'
|
2
|
+
require_relative 'glfw/stubs'
|
3
|
+
require_relative 'glfw/constants'
|
4
|
+
require_relative 'glfw/glfw'
|
@@ -0,0 +1,365 @@
|
|
1
|
+
|
2
|
+
module GLFW
|
3
|
+
|
4
|
+
class Cursor
|
5
|
+
|
6
|
+
##
|
7
|
+
# Standard "arror" cursor shape.
|
8
|
+
SHAPE_ARROW = 0x00036001
|
9
|
+
|
10
|
+
##
|
11
|
+
# I-beam cursor shape, commonly used for text editing.
|
12
|
+
SHAPE_IBEAM = 0x00036002
|
13
|
+
|
14
|
+
##
|
15
|
+
# Cross-hair cursor shape
|
16
|
+
SHAPE_CROSSHAIR = 0x00036003
|
17
|
+
|
18
|
+
##
|
19
|
+
# Hand cursor shape, common for clickable links, move, drag, etc.
|
20
|
+
SHAPE_HAND = 0x00036004
|
21
|
+
|
22
|
+
##
|
23
|
+
# Horizontal-resize cursor shape.
|
24
|
+
SHAPE_HRESIZE = 0x00036005
|
25
|
+
|
26
|
+
##
|
27
|
+
# Vertical-resize cursor shape.
|
28
|
+
SHAPE_VRESIZE = 0x00036006
|
29
|
+
end
|
30
|
+
|
31
|
+
class Window
|
32
|
+
|
33
|
+
# @!group Cursor Mode
|
34
|
+
|
35
|
+
##
|
36
|
+
# The cursor is visible and behaves normally.
|
37
|
+
CURSOR_NORMAL = 0x00034001
|
38
|
+
|
39
|
+
##
|
40
|
+
# The cursor is invisible when it is over the content area of the window but does not restrict the cursor from leaving.
|
41
|
+
CURSOR_HIDDEN = 0x00034002
|
42
|
+
|
43
|
+
##
|
44
|
+
# The application window hides and grabs the cursor, providing virtual and unlimited cursor movement, useful for implementing 3D camera controls.
|
45
|
+
CURSOR_DISABLED = 0x00034003
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
class GamepadState
|
50
|
+
|
51
|
+
# @!group Gamepad Axes
|
52
|
+
|
53
|
+
AXIS_LEFT_X = 0
|
54
|
+
AXIS_LEFT_Y = 1
|
55
|
+
AXIS_RIGHT_X = 2
|
56
|
+
AXIS_RIGHT_Y = 3
|
57
|
+
AXIS_LEFT_TRIGGER = 4
|
58
|
+
AXIS_RIGHT_TRIGGER = 5
|
59
|
+
|
60
|
+
# @!group Gamepad Buttons
|
61
|
+
|
62
|
+
BUTTON_A = 0
|
63
|
+
BUTTON_B = 1
|
64
|
+
BUTTON_X = 2
|
65
|
+
BUTTON_Y = 3
|
66
|
+
BUTTON_LEFT_BUMPER = 4
|
67
|
+
BUTTON_RIGHT_BUMPER = 5
|
68
|
+
BUTTON_BACK = 6
|
69
|
+
BUTTON_START = 7
|
70
|
+
BUTTON_GUIDE = 8
|
71
|
+
BUTTON_LEFT_THUMB = 9
|
72
|
+
BUTTON_RIGHT_THUMB = 10
|
73
|
+
BUTTON_DPAD_UP = 11
|
74
|
+
BUTTON_DPAD_RIGHT = 12
|
75
|
+
BUTTON_DPAD_DOWN = 13
|
76
|
+
BUTTON_DPAD_LEFT = 14
|
77
|
+
BUTTON_CROSS = BUTTON_A
|
78
|
+
BUTTON_CIRCLE = BUTTON_B
|
79
|
+
BUTTON_SQUARE = BUTTON_X
|
80
|
+
BUTTON_TRIANGLE = BUTTON_Y
|
81
|
+
end
|
82
|
+
|
83
|
+
# @!group Input States
|
84
|
+
|
85
|
+
RELEASE = 0
|
86
|
+
PRESS = 1
|
87
|
+
REPEAT = 2
|
88
|
+
|
89
|
+
# @!group Printable Keys
|
90
|
+
|
91
|
+
KEY_SPACE = 32
|
92
|
+
KEY_APOSTROPHE = 39
|
93
|
+
KEY_COMMA = 44
|
94
|
+
KEY_MINUS = 45
|
95
|
+
KEY_PERIOD = 46
|
96
|
+
KEY_SLASH = 47
|
97
|
+
KEY_0 = 48
|
98
|
+
KEY_1 = 49
|
99
|
+
KEY_2 = 50
|
100
|
+
KEY_3 = 51
|
101
|
+
KEY_4 = 52
|
102
|
+
KEY_5 = 53
|
103
|
+
KEY_6 = 54
|
104
|
+
KEY_7 = 55
|
105
|
+
KEY_8 = 56
|
106
|
+
KEY_9 = 57
|
107
|
+
KEY_SEMICOLON = 59
|
108
|
+
KEY_EQUAL = 61
|
109
|
+
KEY_A = 65
|
110
|
+
KEY_B = 66
|
111
|
+
KEY_C = 67
|
112
|
+
KEY_D = 68
|
113
|
+
KEY_E = 69
|
114
|
+
KEY_F = 70
|
115
|
+
KEY_G = 71
|
116
|
+
KEY_H = 72
|
117
|
+
KEY_I = 73
|
118
|
+
KEY_J = 74
|
119
|
+
KEY_K = 75
|
120
|
+
KEY_L = 76
|
121
|
+
KEY_M = 77
|
122
|
+
KEY_N = 78
|
123
|
+
KEY_O = 79
|
124
|
+
KEY_P = 80
|
125
|
+
KEY_Q = 81
|
126
|
+
KEY_R = 82
|
127
|
+
KEY_S = 83
|
128
|
+
KEY_T = 84
|
129
|
+
KEY_U = 85
|
130
|
+
KEY_V = 86
|
131
|
+
KEY_W = 87
|
132
|
+
KEY_X = 88
|
133
|
+
KEY_Y = 89
|
134
|
+
KEY_Z = 90
|
135
|
+
KEY_LEFT_BRACKET = 91
|
136
|
+
KEY_BACKSLASH = 92
|
137
|
+
KEY_RIGHT_BRACKET = 93
|
138
|
+
KEY_GRAVE_ACCENT = 96
|
139
|
+
KEY_WORLD_1 = 161
|
140
|
+
KEY_WORLD_2 = 162
|
141
|
+
|
142
|
+
# @!group Non-printable Keys
|
143
|
+
|
144
|
+
# An unknown/invalid key
|
145
|
+
KEY_UNKNOWN = -1
|
146
|
+
KEY_ESCAPE = 256
|
147
|
+
KEY_ENTER = 257
|
148
|
+
KEY_TAB = 258
|
149
|
+
KEY_BACKSPACE = 259
|
150
|
+
KEY_INSERT = 260
|
151
|
+
KEY_DELETE = 261
|
152
|
+
KEY_RIGHT = 262
|
153
|
+
KEY_LEFT = 263
|
154
|
+
KEY_DOWN = 264
|
155
|
+
KEY_UP = 265
|
156
|
+
KEY_PAGE_UP = 266
|
157
|
+
KEY_PAGE_DOWN = 267
|
158
|
+
KEY_HOME = 268
|
159
|
+
KEY_END = 269
|
160
|
+
KEY_CAPS_LOCK = 280
|
161
|
+
KEY_SCROLL_LOCK = 281
|
162
|
+
KEY_NUM_LOCK = 282
|
163
|
+
KEY_PRINT_SCREEN = 283
|
164
|
+
KEY_PAUSE = 284
|
165
|
+
KEY_F1 = 290
|
166
|
+
KEY_F2 = 291
|
167
|
+
KEY_F3 = 292
|
168
|
+
KEY_F4 = 293
|
169
|
+
KEY_F5 = 294
|
170
|
+
KEY_F6 = 295
|
171
|
+
KEY_F7 = 296
|
172
|
+
KEY_F8 = 297
|
173
|
+
KEY_F9 = 298
|
174
|
+
KEY_F10 = 299
|
175
|
+
KEY_F11 = 300
|
176
|
+
KEY_F12 = 301
|
177
|
+
KEY_F13 = 302
|
178
|
+
KEY_F14 = 303
|
179
|
+
KEY_F15 = 304
|
180
|
+
KEY_F16 = 305
|
181
|
+
KEY_F17 = 306
|
182
|
+
KEY_F18 = 307
|
183
|
+
KEY_F19 = 308
|
184
|
+
KEY_F20 = 309
|
185
|
+
KEY_F21 = 310
|
186
|
+
KEY_F22 = 311
|
187
|
+
KEY_F23 = 312
|
188
|
+
KEY_F24 = 313
|
189
|
+
KEY_F25 = 314
|
190
|
+
KEY_KP_0 = 320
|
191
|
+
KEY_KP_1 = 321
|
192
|
+
KEY_KP_2 = 322
|
193
|
+
KEY_KP_3 = 323
|
194
|
+
KEY_KP_4 = 324
|
195
|
+
KEY_KP_5 = 325
|
196
|
+
KEY_KP_6 = 326
|
197
|
+
KEY_KP_7 = 327
|
198
|
+
KEY_KP_8 = 328
|
199
|
+
KEY_KP_9 = 329
|
200
|
+
KEY_KP_DECIMAL = 330
|
201
|
+
KEY_KP_DIVIDE = 331
|
202
|
+
KEY_KP_MULTIPLY = 332
|
203
|
+
KEY_KP_SUBTRACT = 333
|
204
|
+
KEY_KP_ADD = 334
|
205
|
+
KEY_KP_ENTER = 335
|
206
|
+
KEY_KP_EQUAL = 336
|
207
|
+
KEY_LEFT_SHIFT = 340
|
208
|
+
KEY_LEFT_CONTROL = 341
|
209
|
+
KEY_LEFT_ALT = 342
|
210
|
+
KEY_LEFT_SUPER = 343
|
211
|
+
KEY_RIGHT_SHIFT = 344
|
212
|
+
KEY_RIGHT_CONTROL = 345
|
213
|
+
KEY_RIGHT_ALT = 346
|
214
|
+
KEY_RIGHT_SUPER = 347
|
215
|
+
KEY_MENU = 348
|
216
|
+
|
217
|
+
# @!group Modifier Keys
|
218
|
+
|
219
|
+
MOD_SHIFT = 0x0001
|
220
|
+
MOD_CONTROL = 0x0002
|
221
|
+
MOD_ALT = 0x0004
|
222
|
+
MOD_SUPER = 0x0008
|
223
|
+
MOD_CAPS_LOCK = 0x0010
|
224
|
+
MOD_NUM_LOCK = 0x0020
|
225
|
+
|
226
|
+
# @!group Joystick Hats
|
227
|
+
|
228
|
+
HAT_CENTERED = 0
|
229
|
+
HAT_UP = 1
|
230
|
+
HAT_RIGHT = 2
|
231
|
+
HAT_DOWN = 4
|
232
|
+
HAT_LEFT = 8
|
233
|
+
HAT_RIGHT_UP = HAT_RIGHT | HAT_UP
|
234
|
+
HAT_RIGHT_DOWN = HAT_RIGHT | HAT_DOWN
|
235
|
+
HAT_LEFT_UP = HAT_LEFT | HAT_UP
|
236
|
+
HAT_LEFT_DOWN = HAT_LEFT | HAT_DOWN
|
237
|
+
|
238
|
+
# @!group Mouse Buttons
|
239
|
+
|
240
|
+
MOUSE_BUTTON_1 = 0
|
241
|
+
MOUSE_BUTTON_2 = 1
|
242
|
+
MOUSE_BUTTON_3 = 2
|
243
|
+
MOUSE_BUTTON_4 = 3
|
244
|
+
MOUSE_BUTTON_5 = 4
|
245
|
+
MOUSE_BUTTON_6 = 5
|
246
|
+
MOUSE_BUTTON_7 = 6
|
247
|
+
MOUSE_BUTTON_8 = 7
|
248
|
+
MOUSE_BUTTON_LAST = MOUSE_BUTTON_8
|
249
|
+
MOUSE_BUTTON_LEFT = MOUSE_BUTTON_1
|
250
|
+
MOUSE_BUTTON_RIGHT = MOUSE_BUTTON_2
|
251
|
+
MOUSE_BUTTON_MIDDLE = MOUSE_BUTTON_3
|
252
|
+
|
253
|
+
# @!group Joystick Identifiers
|
254
|
+
|
255
|
+
JOYSTICK_1 = 0
|
256
|
+
JOYSTICK_2 = 1
|
257
|
+
JOYSTICK_3 = 2
|
258
|
+
JOYSTICK_4 = 3
|
259
|
+
JOYSTICK_5 = 4
|
260
|
+
JOYSTICK_6 = 5
|
261
|
+
JOYSTICK_7 = 6
|
262
|
+
JOYSTICK_8 = 7
|
263
|
+
JOYSTICK_9 = 8
|
264
|
+
JOYSTICK_10 = 9
|
265
|
+
JOYSTICK_11 = 10
|
266
|
+
JOYSTICK_12 = 11
|
267
|
+
JOYSTICK_13 = 12
|
268
|
+
JOYSTICK_14 = 13
|
269
|
+
JOYSTICK_15 = 14
|
270
|
+
JOYSTICK_16 = 15
|
271
|
+
|
272
|
+
# @!group Error Codes
|
273
|
+
|
274
|
+
ERR_NOT_INITIALIZED = 0x00010001
|
275
|
+
ERR_NO_CURRENT_CONTEXT = 0x00010002
|
276
|
+
ERR_INVALID_ENUM = 0x00010003
|
277
|
+
ERR_INVALID_VALUE = 0x00010004
|
278
|
+
ERR_OUT_OF_MEMORY = 0x00010005
|
279
|
+
ERR_API_UNAVAILABLE = 0x00010006
|
280
|
+
ERR_VERSION_UNAVAILABLE = 0x00010007
|
281
|
+
ERR_PLATFORM_ERROR = 0x00010008
|
282
|
+
ERR_FORMAT_UNAVAILABLE = 0x00010009
|
283
|
+
ERR_NO_WINDOW_CONTEXT = 0x0001000A
|
284
|
+
|
285
|
+
# @!group Window Hints
|
286
|
+
|
287
|
+
HINT_RESIZABLE = 0x00020003
|
288
|
+
HINT_VISIBLE = 0x00020004
|
289
|
+
HINT_DECORATED = 0x00020005
|
290
|
+
HINT_AUTO_ICONIFY = 0x00020006
|
291
|
+
HINT_FLOATING = 0x00020007
|
292
|
+
HINT_MAXIMIZED = 0x00020008
|
293
|
+
HINT_CENTER_CURSOR = 0x00020009
|
294
|
+
HINT_TRANSPARENT_FRAMEBUFFER = 0x0002000A
|
295
|
+
HINT_FOCUS_ON_SHOW = 0x0002000C
|
296
|
+
HINT_SCALE_TO_MONITOR = 0x0002200C
|
297
|
+
HINT_RED_BITS = 0x00021001
|
298
|
+
HINT_GREEN_BITS = 0x00021002
|
299
|
+
HINT_BLUE_BITS = 0x00021003
|
300
|
+
HINT_ALPHA_BITS = 0x00021004
|
301
|
+
HINT_DEPTH_BITS = 0x00021005
|
302
|
+
HINT_STENCIL_BITS = 0x00021006
|
303
|
+
HINT_ACCUM_RED_BITS = 0x00021007
|
304
|
+
HINT_ACCUM_GREEN_BITS = 0x00021008
|
305
|
+
HINT_ACCUM_BLUE_BITS = 0x00021009
|
306
|
+
HINT_ACCUM_ALPHA_BITS = 0x0002100A
|
307
|
+
HINT_AUX_BUFFERS = 0x0002100B
|
308
|
+
HINT_SAMPLES = 0x0002100D
|
309
|
+
HINT_REFRESH_RATE = 0x0002100F
|
310
|
+
HINT_STEREO = 0x0002100C
|
311
|
+
HINT_SRGB_CAPABLE = 0x0002100E
|
312
|
+
HINT_DOUBLEBUFFER = 0x00021010
|
313
|
+
HINT_CLIENT_API = 0x00022001
|
314
|
+
HINT_CONTEXT_VERSION_MAJOR = 0x00022002
|
315
|
+
HINT_CONTEXT_VERSION_MINOR = 0x00022003
|
316
|
+
HINT_CONTEXT_REVISION = 0x00022004
|
317
|
+
HINT_CONTEXT_ROBUSTNESS = 0x00022005
|
318
|
+
HINT_CONTEXT_RELEASE_BEHAVIOR = 0x00022009
|
319
|
+
HINT_OPENGL_FORWARD_COMPAT = 0x00022006
|
320
|
+
HINT_OPENGL_DEBUG_CONTEXT = 0x00022007
|
321
|
+
HINT_OPENGL_PROFILE = 0x00022008
|
322
|
+
HINT_COCOA_RETINA_FRAMEBUFFER = 0x00023001
|
323
|
+
HINT_COCOA_FRAME_NAME = 0x00023002
|
324
|
+
HINT_COCOA_GRAPHICS_SWITCHING = 0x00023003
|
325
|
+
HINT_X11_CLASS_NAME = 0x00024001
|
326
|
+
HINT_X11_INSTANCE_NAME = 0x00024002
|
327
|
+
HINT_CONTEXT_NO_ERROR = 0x0002200A
|
328
|
+
HINT_CONTEXT_CREATION_API = 0x0002200B
|
329
|
+
|
330
|
+
# @!group Values for HINT_RELEASE_BEHAVIOR
|
331
|
+
|
332
|
+
RELEASE_BEHAVIOR_ANY = 0
|
333
|
+
RELEASE_BEHAVIOR_FLUSH = 0x00035001
|
334
|
+
RELEASE_BEHAVIOR_NONE = 0x00035002
|
335
|
+
|
336
|
+
# @!group Values for HINT_CONTEXT_CREATION_API
|
337
|
+
|
338
|
+
CONTEXT_API_NATIVE = 0x00036001
|
339
|
+
CONTEXT_API_EGL = 0x00036002
|
340
|
+
CONTEXT_API_OSMESA = 0x00036003
|
341
|
+
|
342
|
+
# @!group Values for HINT_CLIENT_API
|
343
|
+
|
344
|
+
API_NONE = 0
|
345
|
+
API_OPENGL = 0x00030001
|
346
|
+
API_OPENGL_ES = 0x00030002
|
347
|
+
|
348
|
+
# @!group Values for HINT_OPENGL_PROFILE
|
349
|
+
|
350
|
+
PROFILE_OPENGL_ANY = 0
|
351
|
+
PROFILE_OPENGL_CORE = 0x00032001
|
352
|
+
PROFILE_OPENGL_COMPAT = 0x00032002
|
353
|
+
|
354
|
+
# @!group Value for HINT_CONTEXT_ROBUSTNESS
|
355
|
+
|
356
|
+
ROBUSTNESS_NONE = 0
|
357
|
+
ROBUSTNESS_NO_RESET_NOTIFICATION = 0x00031001
|
358
|
+
ROBUSTNESS_LOSE_CONTEXT_ON_RESET = 0x00031002
|
359
|
+
|
360
|
+
# @!group Library initialization hints
|
361
|
+
|
362
|
+
JOYSTICK_HAT_BUTTONS = 0x00050001
|
363
|
+
COCOA_CHDIR_RESOURCES = 0x00051001
|
364
|
+
COCOA_MENUBAR = 0x00051002
|
365
|
+
end
|
data/lib/glfw/stubs.rb
ADDED
@@ -0,0 +1,234 @@
|
|
1
|
+
|
2
|
+
require_relative 'stubs/window'
|
3
|
+
require_relative 'stubs/image'
|
4
|
+
require_relative 'stubs/gamepad_state'
|
5
|
+
require_relative 'stubs/cursor'
|
6
|
+
require_relative 'stubs/joystick'
|
7
|
+
require_relative 'stubs/monitor'
|
8
|
+
require_relative 'stubs/video_mode'
|
9
|
+
|
10
|
+
module GLFW
|
11
|
+
|
12
|
+
class << self
|
13
|
+
|
14
|
+
##
|
15
|
+
# Initializes the GLFW library. This method must be called before attempting to use any other feature, or
|
16
|
+
# after a call to {terminate} was made.
|
17
|
+
#
|
18
|
+
# @overload init
|
19
|
+
# When called without a block, returns a value indicating if library initialized successfully.
|
20
|
+
# @return [Boolean] `true` if library initialized successfully, otherwise `false`.
|
21
|
+
# @note Calling this method while library is already initialized is a no-op and returns `true` immediately.
|
22
|
+
# @overload init(&block)
|
23
|
+
# When called with a block, yields and automatically calls {terminate} when the block exits.
|
24
|
+
# @return [void]
|
25
|
+
#
|
26
|
+
# @see terminate
|
27
|
+
# @see
|
28
|
+
def init
|
29
|
+
end
|
30
|
+
|
31
|
+
##
|
32
|
+
# Destroys the all windows, their contexts, cursors, etc., restoring the library to an uninitialized state.
|
33
|
+
#
|
34
|
+
# @return [void]
|
35
|
+
# @see init
|
36
|
+
def terminate
|
37
|
+
end
|
38
|
+
|
39
|
+
##
|
40
|
+
# Sets hints that affect how the library behaves until termination.
|
41
|
+
#
|
42
|
+
# @param hint [Integer] A value indicating the hint to change.
|
43
|
+
# @param value [Integer,Boolean,String] The desired value to set for this hint.
|
44
|
+
#
|
45
|
+
# @return [void]
|
46
|
+
# @see JOYSTICK_HAT_BUTTONS
|
47
|
+
# @see COCOA_CHDIR_RESOURCES
|
48
|
+
# @see COCOA_MENUBAR
|
49
|
+
def init_hint(hint, value)
|
50
|
+
end
|
51
|
+
|
52
|
+
##
|
53
|
+
# Returns whether the specified API extension is supported by the current OpenGL or OpenGL ES context. It searches
|
54
|
+
# both for client API extension and context creation API extensions.
|
55
|
+
#
|
56
|
+
# A context must be current on the calling thread.
|
57
|
+
#
|
58
|
+
# @param extenion_name [String] The name of an extension to query.
|
59
|
+
# @return [Boolean] `true` if extension is supported, otherwise `false`.
|
60
|
+
def supported?(extension_name)
|
61
|
+
end
|
62
|
+
|
63
|
+
##
|
64
|
+
# This function sets the swap interval for the current OpenGL or OpenGL ES context, i.e. the number of
|
65
|
+
# screen updates to wait from the time {Window.swap_buffers} was called before swapping the buffers and
|
66
|
+
# returning. This is sometimes called vertical synchronization, vertical retrace synchronization or just vsync.
|
67
|
+
#
|
68
|
+
# @param interval [Integer] The minimum number of screen updates to wait for until the buffers are swapped by {Window.swap_buffers}
|
69
|
+
#
|
70
|
+
# @return [void]
|
71
|
+
def swap_interval(interval)
|
72
|
+
end
|
73
|
+
|
74
|
+
##
|
75
|
+
# Processes only those events that are already in the event queue and then returns immediately.
|
76
|
+
# Processing events will cause the window and input callbacks associated with those events to be called.
|
77
|
+
# @return [void]
|
78
|
+
def poll_events
|
79
|
+
end
|
80
|
+
|
81
|
+
##
|
82
|
+
# puts the calling thread to sleep until at least one event is available in the event queue.
|
83
|
+
# Once one or more events are available, it behaves exactly like {poll_events}.
|
84
|
+
# @return [void]
|
85
|
+
def wait_events
|
86
|
+
end
|
87
|
+
|
88
|
+
##
|
89
|
+
# Posts an empty event from the current thread to the event queue, causing {wait_vents} or {events_timeout} to return.
|
90
|
+
# @return [void]
|
91
|
+
def post_empty_event
|
92
|
+
end
|
93
|
+
|
94
|
+
##
|
95
|
+
# Puts the calling thread to sleep until at least one event is available in the event queue, or until the specified
|
96
|
+
# timeout is reached. If one or more events are available, it behaves exactly like {poll_events}.
|
97
|
+
#
|
98
|
+
# @param timeout [Float] The maximum amount of time, in seconds, to wait.
|
99
|
+
# @return [void]
|
100
|
+
def event_timeout(timeout)
|
101
|
+
end
|
102
|
+
|
103
|
+
##
|
104
|
+
# Returns a function pointer for the specified OpenGL function, as a [Fiddle::Pointer](https://ruby-doc.org/stdlib-2.5.3/libdoc/fiddle/rdoc/Fiddle/Pointer.html).
|
105
|
+
#
|
106
|
+
# @param name [String] The name of an OpenGL function.
|
107
|
+
#
|
108
|
+
# @return [Fiddle::Pointer] a function pointer.
|
109
|
+
def proc_address(name)
|
110
|
+
end
|
111
|
+
|
112
|
+
##
|
113
|
+
# Convenience method for importing OpenGL functions using Fiddle (standard library since Ruby 1.9)
|
114
|
+
#
|
115
|
+
# @param name [String] The name of an OpenGL function.
|
116
|
+
# @param args [Array<Integer>] An array describing the argument prototypes, same as when creating a [Fiddle::Function](https://ruby-doc.org/stdlib-2.5.3/libdoc/fiddle/rdoc/Fiddle/Function.html#method-c-new).
|
117
|
+
# @param return_type [Integer] A value describing the argument prototypes, same as when creating a [Fiddle::Function](https://ruby-doc.org/stdlib-2.5.3/libdoc/fiddle/rdoc/Fiddle/Function.html#method-c-new).
|
118
|
+
#
|
119
|
+
# @return [Fiddle::Function]
|
120
|
+
# @see https://ruby-doc.org/stdlib-2.5.3/libdoc/fiddle/rdoc/Fiddle/Function.html
|
121
|
+
def import(name, args, return_type)
|
122
|
+
end
|
123
|
+
|
124
|
+
##
|
125
|
+
# Returns the name of the specified printable key, encoded as UTF-8. This is typically the character that key
|
126
|
+
# would produce without any modifier keys, intended for displaying key bindings to the user. For dead keys, it
|
127
|
+
# is typically the diacritic it would add to a character.
|
128
|
+
#
|
129
|
+
# @param key [Integer] The key to query.
|
130
|
+
# @param scancode [Integer] The scancode of the key to query.
|
131
|
+
#
|
132
|
+
# @note When `scancode` is specified, the `key` argument is ignored.
|
133
|
+
#
|
134
|
+
# @return [String?] The UTF-8 encoded, layout-specific name of the key, or `nil`.
|
135
|
+
def key_name(key, scancode = 0)
|
136
|
+
end
|
137
|
+
|
138
|
+
##
|
139
|
+
# returns the platform-specific scancode of the specified key.
|
140
|
+
#
|
141
|
+
# @param key [Integer] The key to query.
|
142
|
+
#
|
143
|
+
# @return [Integer] the platform-specific scancode for the key, or `-1` if an error occurred.
|
144
|
+
def scancode(key)
|
145
|
+
end
|
146
|
+
|
147
|
+
##
|
148
|
+
# @return [String] the version of the native GLFW library, in "MAJOR.MINOR.REVISION" format.
|
149
|
+
attr_reader :version
|
150
|
+
|
151
|
+
##
|
152
|
+
# @return [String] a version string, including information such as driver version, etc.
|
153
|
+
attr_reader :version_str
|
154
|
+
|
155
|
+
##
|
156
|
+
# @return [Integer] the current value of the raw timer, measured in 1 / {timer_frequency) seconds.
|
157
|
+
attr_reader :timer_value
|
158
|
+
|
159
|
+
##
|
160
|
+
# @return [Integer] the frequency, in Hz, of the raw timer.
|
161
|
+
attr_reader :timer_frequency
|
162
|
+
|
163
|
+
##
|
164
|
+
# The current time measured by GLFW, in seconds.
|
165
|
+
# Unless the time has been set using glfwSetTime it measures time elapsed since GLFW was initialized.
|
166
|
+
#
|
167
|
+
# The resolution of the timer is system dependent, but is usually on the order of a few micro- or nanoseconds.
|
168
|
+
# It uses the highest-resolution monotonic time source on each supported platform.
|
169
|
+
#
|
170
|
+
# @return [Float] the current GLFW time, in seconds.
|
171
|
+
attr_accessor :time
|
172
|
+
end
|
173
|
+
|
174
|
+
##
|
175
|
+
# Describes a 2-component floating point vector.
|
176
|
+
class Vec2
|
177
|
+
|
178
|
+
##
|
179
|
+
# @return [Float] the position on the x-axis.
|
180
|
+
attr_accessor :x
|
181
|
+
|
182
|
+
##
|
183
|
+
# @return [Float] the position on the y-axis.
|
184
|
+
attr_accessor :y
|
185
|
+
|
186
|
+
##
|
187
|
+
# Creates a new instance of the {Vec2} class.
|
188
|
+
# @param x [Float] The position on the x-axis.
|
189
|
+
# @param y [Float] The position on the y-axis.
|
190
|
+
def initialize(x, y)
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
194
|
+
|
195
|
+
##
|
196
|
+
# Descibes the location of an object in 2D space.
|
197
|
+
class Point
|
198
|
+
|
199
|
+
##
|
200
|
+
# @return [Integer] the position on the x-axis.
|
201
|
+
attr_accessor :x
|
202
|
+
|
203
|
+
##
|
204
|
+
# @return [Integer] the position on the y-axis.
|
205
|
+
attr_accessor :y
|
206
|
+
|
207
|
+
##
|
208
|
+
# Creates a new instance of the {Point} class.
|
209
|
+
# @param x [Integer] The position on the x-axis.
|
210
|
+
# @param y [Integer] The position on the y-axis.
|
211
|
+
def initialize(x, y)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
##
|
216
|
+
# Describes the dimensions of an object in 2D space.
|
217
|
+
class Size
|
218
|
+
|
219
|
+
##
|
220
|
+
# @return [Integer] the dimension on the x-axis.
|
221
|
+
attr_accessor :width
|
222
|
+
|
223
|
+
##
|
224
|
+
# @return [Integer] the dimension on the y-axis.
|
225
|
+
attr_accessor :height
|
226
|
+
|
227
|
+
##
|
228
|
+
# Creates a new instance of the {Size} class.
|
229
|
+
# @param width [Integer] The dimension on the x-axis.
|
230
|
+
# @param height [Integer] The dimension on the y-axis.
|
231
|
+
def initialize(width, height)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|