glfw3 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ext/glfw3/glfw3.c ADDED
@@ -0,0 +1,1286 @@
1
+ #include "ruby.h"
2
+ #include <GLFW/glfw3.h>
3
+
4
+
5
+ typedef struct s_rb_glfw_error
6
+ {
7
+ VALUE error_code; // mark
8
+ VALUE description; // mark
9
+ } rb_glfw_error_t;
10
+
11
+
12
+ static const char *kRB_IVAR_WINDOW_INTERNAL = "@__internal_window";
13
+ static const char *kRB_IVAR_WINDOW_KEY_CALLBACK = "@__key_callback";
14
+ static const char *kRB_IVAR_WINDOW_CHAR_CALLBACK = "@__char_callback";
15
+ static const char *kRB_IVAR_WINDOW_MOUSE_BUTTON_CALLBACK = "@__mouse_button_callback";
16
+ static const char *kRB_IVAR_WINDOW_CURSOR_POSITION_CALLBACK = "@__cursor_position_callback";
17
+ static const char *kRB_IVAR_WINDOW_CURSOR_ENTER_CALLBACK = "@__cursor_enter_callback";
18
+ static const char *kRB_IVAR_WINDOW_SCROLL_CALLBACK = "@__scroll_callback";
19
+ static const char *kRB_IVAR_WINDOW_POSITION_CALLBACK = "@__position_callback";
20
+ static const char *kRB_IVAR_WINDOW_SIZE_CALLBACK = "@__size_callback";
21
+ static const char *kRB_IVAR_WINDOW_CLOSE_CALLBACK = "@__close_callback";
22
+ static const char *kRB_IVAR_WINDOW_REFRESH_CALLBACK = "@__refresh_callback";
23
+ static const char *kRB_IVAR_WINDOW_FOCUS_CALLBACK = "@__focus_callback";
24
+ static const char *kRB_IVAR_WINDOW_ICONIFY_CALLBACK = "@__iconify_callback";
25
+ static const char *kRB_IVAR_WINDOW_FRAMEBUFFER_SIZE_CALLBACK = "@__framebuffer_size_callback";
26
+ static const char *kRB_CVAR_WINDOW_WINDOWS = "@@__windows";
27
+ static const char *kRB_CVAR_GLFW_ERROR_CALLBACK = "@@__error_callback";
28
+ static const char *kRB_CVAR_GLFW_MONITOR_CALLBACK = "@@__monitor_callback";
29
+
30
+
31
+ static VALUE s_glfw_module = Qundef;
32
+ static VALUE s_glfw_window_klass = Qundef;
33
+ static VALUE s_glfw_window_internal_klass = Qundef;
34
+ static VALUE s_glfw_monitor_klass = Qundef;
35
+ static VALUE s_glfw_videomode_klass = Qundef;
36
+
37
+
38
+ static void rb_glfw_error_callback(int error_code, const char *description);
39
+ static void rb_glfw_monitor_callback(GLFWmonitor *monitor, int message);
40
+
41
+
42
+ #define RB_ENABLE_CALLBACK_DEF(NAME, CALLBACK, GLFW_FUNC) \
43
+ static VALUE NAME (VALUE self, VALUE enabled) \
44
+ { \
45
+ if (RTEST(enabled)) { \
46
+ GLFW_FUNC ( rb_get_window(self), CALLBACK ); \
47
+ } else { \
48
+ GLFW_FUNC ( rb_get_window(self), NULL ); \
49
+ } \
50
+ return self; \
51
+ }
52
+
53
+
54
+ /* GLFWAPI int glfwInit(void); */
55
+
56
+ static VALUE rb_glfw_init(VALUE self)
57
+ {
58
+ (void)self;
59
+ VALUE result = glfwInit() ? Qtrue : Qfalse;
60
+ if (result == Qtrue) {
61
+ glfwSetMonitorCallback(rb_glfw_monitor_callback);
62
+ }
63
+ return result;
64
+ }
65
+
66
+
67
+
68
+
69
+ /* GLFWAPI void glfwTerminate(void); */
70
+
71
+ static VALUE rb_glfw_terminate(VALUE self)
72
+ {
73
+ glfwTerminate();
74
+ return Qundef;
75
+ }
76
+
77
+
78
+
79
+ /* GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev); */
80
+
81
+ static VALUE rb_glfw_version(VALUE self)
82
+ {
83
+ int major = 0;
84
+ int minor = 0;
85
+ int revision = 0;
86
+ glfwGetVersion(&major, &minor, &revision);
87
+ return rb_ary_new3(3, INT2NUM(major), INT2NUM(minor), INT2NUM(revision));
88
+ }
89
+
90
+
91
+
92
+ /* GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun); */
93
+
94
+ static void rb_glfw_error_callback(int error_code, const char *description)
95
+ {
96
+ VALUE lambda = rb_cvar_get(s_glfw_module, rb_intern(kRB_CVAR_GLFW_ERROR_CALLBACK));
97
+
98
+
99
+
100
+ if (RTEST(lambda)) {
101
+ VALUE rb_description = rb_str_new2(description);
102
+ VALUE rb_error_code = INT2FIX(error_code);
103
+ OBJ_FREEZE(rb_description);
104
+ OBJ_FREEZE(rb_error_code);
105
+ rb_funcall(lambda, rb_intern("call"), 2, rb_error_code, rb_description);
106
+ } else {
107
+ rb_raise(rb_eRuntimeError, "GLFW Error 0x%X: %s", error_code, description);
108
+ }
109
+ }
110
+
111
+
112
+
113
+ /* GLFWAPI GLFWmonitor** glfwGetMonitors(int* count); */
114
+
115
+ VALUE rb_glfw_get_monitors(VALUE self)
116
+ {
117
+ long monitor_index = 0;
118
+ int num_monitors = 0;
119
+ GLFWmonitor **monitors = glfwGetMonitors(&num_monitors);
120
+ VALUE monitors_out = rb_ary_new();
121
+ for (; num_monitors; --num_monitors, ++monitor_index) {
122
+ VALUE monitor = Data_Wrap_Struct(s_glfw_monitor_klass, 0, 0, monitors[monitor_index]);
123
+ rb_obj_call_init(monitor, 0, 0);
124
+ rb_ary_push(monitors_out, monitor);
125
+ }
126
+ return monitors_out;
127
+ }
128
+
129
+
130
+
131
+ /* GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void); */
132
+
133
+ VALUE rb_glfw_get_primary_monitor(VALUE self)
134
+ {
135
+ VALUE monitor = Data_Wrap_Struct(s_glfw_monitor_klass, 0, 0, glfwGetPrimaryMonitor());
136
+ rb_obj_call_init(monitor, 0, 0);
137
+ return monitor;
138
+ }
139
+
140
+
141
+
142
+ /* GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos); */
143
+
144
+ VALUE rb_monitor_position(VALUE self)
145
+ {
146
+ GLFWmonitor *monitor;
147
+ Data_Get_Struct(self, GLFWmonitor, monitor);
148
+ int xpos = 0;
149
+ int ypos = 0;
150
+ glfwGetMonitorPos(monitor, &xpos, &ypos);
151
+ return rb_ary_new3(2, INT2FIX(xpos), INT2FIX(ypos));
152
+ }
153
+
154
+
155
+
156
+ /* GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* width, int* height); */
157
+
158
+ VALUE rb_monitor_physical_size(VALUE self)
159
+ {
160
+ GLFWmonitor *monitor;
161
+ Data_Get_Struct(self, GLFWmonitor, monitor);
162
+ int width = 0;
163
+ int height = 0;
164
+ glfwGetMonitorPhysicalSize(monitor, &width, &height);
165
+ return rb_ary_new3(2, INT2FIX(width), INT2FIX(height));
166
+ }
167
+
168
+
169
+
170
+ /* GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor); */
171
+
172
+
173
+ VALUE rb_monitor_name(VALUE self)
174
+ {
175
+ GLFWmonitor *monitor;
176
+ Data_Get_Struct(self, GLFWmonitor, monitor);
177
+ return rb_str_new2(glfwGetMonitorName(monitor));
178
+ }
179
+
180
+
181
+
182
+ /* GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun); */
183
+
184
+ static void rb_glfw_monitor_callback(GLFWmonitor *monitor, int message)
185
+ {
186
+ VALUE lambda = rb_cvar_get(s_glfw_module, rb_intern(kRB_CVAR_GLFW_MONITOR_CALLBACK));
187
+ if (RTEST(lambda)) {
188
+ VALUE rb_monitor = Data_Wrap_Struct(s_glfw_monitor_klass, 0, 0, monitor);
189
+ rb_obj_call_init(rb_monitor, 0, 0);
190
+ rb_funcall(lambda, rb_intern("call"), 2, rb_monitor, INT2FIX(message));
191
+ }
192
+ }
193
+
194
+
195
+
196
+ /* GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count); */
197
+
198
+ static VALUE rb_videomode_width(VALUE self)
199
+ {
200
+ GLFWvidmode *mode;
201
+ Data_Get_Struct(self, GLFWvidmode, mode);
202
+ return INT2FIX(mode->width);
203
+ }
204
+
205
+ static VALUE rb_videomode_height(VALUE self)
206
+ {
207
+ GLFWvidmode *mode;
208
+ Data_Get_Struct(self, GLFWvidmode, mode);
209
+ return INT2FIX(mode->height);
210
+ }
211
+
212
+ static VALUE rb_videomode_red_bits(VALUE self)
213
+ {
214
+ GLFWvidmode *mode;
215
+ Data_Get_Struct(self, GLFWvidmode, mode);
216
+ return INT2FIX(mode->redBits);
217
+ }
218
+
219
+ static VALUE rb_videomode_green_bits(VALUE self)
220
+ {
221
+ GLFWvidmode *mode;
222
+ Data_Get_Struct(self, GLFWvidmode, mode);
223
+ return INT2FIX(mode->greenBits);
224
+ }
225
+
226
+ static VALUE rb_videomode_blue_bits(VALUE self)
227
+ {
228
+ GLFWvidmode *mode;
229
+ Data_Get_Struct(self, GLFWvidmode, mode);
230
+ return INT2FIX(mode->blueBits);
231
+ }
232
+
233
+ static VALUE rb_videomode_refresh_rate(VALUE self)
234
+ {
235
+ GLFWvidmode *mode;
236
+ Data_Get_Struct(self, GLFWvidmode, mode);
237
+ return INT2FIX(mode->refreshRate);
238
+ }
239
+
240
+ static VALUE rb_monitor_video_modes(VALUE self)
241
+ {
242
+ GLFWmonitor *monitor;
243
+ Data_Get_Struct(self, GLFWmonitor, monitor);
244
+ VALUE rb_modes = rb_ary_new();
245
+ int num_modes = 0;
246
+ int mode_index = 0;
247
+ const GLFWvidmode *modes = glfwGetVideoModes(monitor, &num_modes);
248
+ for (; num_modes; --num_modes, ++mode_index) {
249
+ GLFWvidmode *mode = ALLOC(GLFWvidmode);
250
+ *mode = modes[mode_index];
251
+ VALUE rb_mode = Data_Wrap_Struct(s_glfw_videomode_klass, 0, free, mode);
252
+ rb_obj_call_init(rb_mode, 0, 0);
253
+ rb_ary_push(rb_modes, rb_mode);
254
+ }
255
+ return rb_modes;
256
+ }
257
+
258
+
259
+
260
+ /* GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor); */
261
+
262
+ static VALUE rb_monitor_video_mode(VALUE self)
263
+ {
264
+ GLFWmonitor *monitor;
265
+ Data_Get_Struct(self, GLFWmonitor, monitor);
266
+ GLFWvidmode *mode = ALLOC(GLFWvidmode);
267
+ *mode = *glfwGetVideoMode(monitor);
268
+ VALUE rb_mode = Data_Wrap_Struct(s_glfw_videomode_klass, 0, free, mode);
269
+ rb_obj_call_init(rb_mode, 0, 0);
270
+ return rb_mode;
271
+ }
272
+
273
+
274
+
275
+ /* GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma); */
276
+
277
+ static VALUE rb_monitor_set_gamma(VALUE self, VALUE gamma)
278
+ {
279
+ GLFWmonitor *monitor;
280
+ Data_Get_Struct(self, GLFWmonitor, monitor);
281
+ glfwSetGamma(monitor, (float)NUM2DBL(gamma));
282
+ return self;
283
+ }
284
+
285
+
286
+
287
+ /* GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor); */
288
+
289
+ #warning "No implementation for glfwGetGammaRamp bindings"
290
+
291
+
292
+
293
+ /* GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp); */
294
+
295
+ #warning "No implementation for glfwSetGammaRamp bindings"
296
+
297
+
298
+
299
+ /* GLFWAPI void glfwDefaultWindowHints(void); */
300
+
301
+ static VALUE rb_window_default_window_hints(VALUE self)
302
+ {
303
+ glfwDefaultWindowHints();
304
+ return self;
305
+ }
306
+
307
+
308
+
309
+ /* GLFWAPI void glfwWindowHint(int target, int hint); */
310
+
311
+ static VALUE rb_window_window_hint(VALUE self, VALUE target, VALUE hint)
312
+ {
313
+ glfwWindowHint(NUM2INT(target), NUM2INT(hint));
314
+ return self;
315
+ }
316
+
317
+
318
+
319
+ /* GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, */
320
+
321
+ static VALUE rb_lookup_window(GLFWwindow *window)
322
+ {
323
+ return (VALUE)glfwGetWindowUserPointer(window);
324
+ }
325
+
326
+ static GLFWwindow *rb_get_window(VALUE rb_window)
327
+ {
328
+ GLFWwindow *window = NULL;
329
+ if (RTEST(rb_window)) {
330
+ ID ivar_window = rb_intern(kRB_IVAR_WINDOW_INTERNAL);
331
+ VALUE rb_window_data = Qnil;
332
+ if (RTEST((rb_window_data = rb_ivar_get(rb_window, ivar_window)))) {
333
+ Data_Get_Struct(rb_window_data, GLFWwindow, window);
334
+ }
335
+ }
336
+ return window;
337
+ }
338
+
339
+ // static VALUE rb_window_init(int argc, VALUE *argv, VALUE self)
340
+ // {
341
+ // return self;
342
+ // }
343
+
344
+ static VALUE rb_window_new(int argc, VALUE *argv, VALUE self)
345
+ {
346
+ ID ivar_window = rb_intern(kRB_IVAR_WINDOW_INTERNAL);
347
+ VALUE rb_width, rb_height, rb_title, rb_monitor, rb_share;
348
+ VALUE rb_window;
349
+ VALUE rb_window_data;
350
+ VALUE rb_windows;
351
+ GLFWwindow *window = NULL;
352
+ int width, height;
353
+ const char *title = "";
354
+ GLFWmonitor *monitor = NULL;
355
+ GLFWwindow *share = NULL;
356
+
357
+ // Grab arguments
358
+ rb_scan_args(argc, argv, "23", &rb_width, &rb_height, &rb_title, &rb_monitor, &rb_share);
359
+
360
+ width = NUM2INT(rb_width);
361
+ height = NUM2INT(rb_height);
362
+
363
+ if (RTEST(rb_title)) {
364
+ if (rb_type(rb_title) != T_STRING) {
365
+ rb_title = rb_any_to_s(rb_title);
366
+ }
367
+ title = StringValueCStr(rb_title);
368
+ }
369
+
370
+ if (RTEST(rb_monitor) && rb_obj_is_instance_of(rb_monitor, s_glfw_monitor_klass)) {
371
+ Data_Get_Struct(rb_monitor, GLFWmonitor, monitor);
372
+ }
373
+
374
+ if (RTEST(rb_share) && rb_obj_is_instance_of(rb_share, s_glfw_window_klass)) {
375
+ VALUE rb_shared_window = rb_ivar_get(rb_share, ivar_window);
376
+ Data_Get_Struct(rb_shared_window, GLFWwindow, share);
377
+ }
378
+
379
+ // Create GLFW window
380
+ window = glfwCreateWindow(width, height, title, monitor, share);
381
+
382
+ // Allocate the window wrapper (only used to store the window pointer)
383
+ rb_window_data = Data_Wrap_Struct(s_glfw_window_internal_klass, 0, 0, window);
384
+ rb_obj_call_init(rb_window_data, 0, 0);
385
+
386
+ // Allocate the window
387
+ rb_window = rb_obj_alloc(s_glfw_window_klass);
388
+
389
+ rb_ivar_set(rb_window, ivar_window, rb_window_data);
390
+ rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_KEY_CALLBACK), Qnil);
391
+ rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_CHAR_CALLBACK), Qnil);
392
+ rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_MOUSE_BUTTON_CALLBACK), Qnil);
393
+ rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_CURSOR_POSITION_CALLBACK), Qnil);
394
+ rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_CURSOR_ENTER_CALLBACK), Qnil);
395
+ rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_SCROLL_CALLBACK), Qnil);
396
+ rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_POSITION_CALLBACK), Qnil);
397
+ rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_SIZE_CALLBACK), Qnil);
398
+ rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_CLOSE_CALLBACK), Qnil);
399
+ rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_REFRESH_CALLBACK), Qnil);
400
+ rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_FOCUS_CALLBACK), Qnil);
401
+ rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_ICONIFY_CALLBACK), Qnil);
402
+ rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_FRAMEBUFFER_SIZE_CALLBACK), Qnil);
403
+
404
+ glfwSetWindowUserPointer(window, (void *)rb_window);
405
+ rb_obj_call_init(rb_window, 0, 0);
406
+
407
+ // Store the window so it can't go out of scope until explicitly destroyed.
408
+ rb_windows = rb_cvar_get(self, rb_intern(kRB_CVAR_WINDOW_WINDOWS));
409
+ rb_hash_aset(rb_windows, INT2FIX((int)window), rb_window);
410
+
411
+ return rb_window;
412
+ }
413
+
414
+
415
+
416
+ /* GLFWAPI void glfwDestroyWindow(GLFWwindow* window); */
417
+
418
+ static VALUE rb_window_destroy(VALUE self)
419
+ {
420
+ GLFWwindow *window = rb_get_window(self);
421
+ if (window) {
422
+ glfwDestroyWindow(window);
423
+ rb_ivar_set(self, rb_intern(kRB_IVAR_WINDOW_INTERNAL), Qnil);
424
+ VALUE rb_windows = rb_cvar_get(s_glfw_window_klass, rb_intern(kRB_CVAR_WINDOW_WINDOWS));
425
+ rb_hash_delete(rb_windows, INT2FIX((int)window));
426
+ }
427
+ return self;
428
+ }
429
+
430
+
431
+
432
+ /* GLFWAPI int glfwWindowShouldClose(GLFWwindow* window); */
433
+
434
+ static VALUE rb_window_should_close(VALUE self)
435
+ {
436
+ GLFWwindow *window = rb_get_window(self);
437
+ return glfwWindowShouldClose(window) ? Qtrue : Qfalse;
438
+ }
439
+
440
+
441
+
442
+ /* GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value); */
443
+
444
+ static VALUE rb_window_set_should_close(VALUE self, VALUE value)
445
+ {
446
+ GLFWwindow *window = rb_get_window(self);
447
+ glfwSetWindowShouldClose(window, RTEST(value) ? GL_TRUE : GL_FALSE);
448
+ return self;
449
+ }
450
+
451
+
452
+
453
+ /* GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title); */
454
+
455
+ static VALUE rb_window_set_title(VALUE self, VALUE title)
456
+ {
457
+ glfwSetWindowTitle(rb_get_window(self), StringValueCStr(title));
458
+ return title;
459
+ }
460
+
461
+
462
+
463
+ /* GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos); */
464
+
465
+ static VALUE rb_window_get_position(VALUE self)
466
+ {
467
+ int xpos = 0;
468
+ int ypos = 0;
469
+ glfwGetWindowPos(rb_get_window(self), &xpos, &ypos);
470
+ return rb_ary_new3(2, INT2FIX(xpos), INT2FIX(ypos));
471
+ }
472
+
473
+
474
+
475
+ /* GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos); */
476
+
477
+ static VALUE rb_window_set_position(VALUE self, VALUE x, VALUE y)
478
+ {
479
+ glfwSetWindowPos(rb_get_window(self), NUM2INT(x), NUM2INT(y));
480
+ return self;
481
+ }
482
+
483
+
484
+
485
+ /* GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height); */
486
+
487
+ static VALUE rb_window_get_size(VALUE self)
488
+ {
489
+ int width = 0;
490
+ int height = 0;
491
+ glfwGetWindowSize(rb_get_window(self), &width, &height);
492
+ return rb_ary_new3(2, INT2FIX(width), INT2FIX(height));
493
+ }
494
+
495
+
496
+
497
+ /* GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height); */
498
+
499
+ static VALUE rb_window_set_size(VALUE self, VALUE width, VALUE height)
500
+ {
501
+ glfwSetWindowSize(rb_get_window(self), NUM2INT(width), NUM2INT(height));
502
+ return self;
503
+ }
504
+
505
+
506
+
507
+ /* GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height); */
508
+
509
+ static VALUE rb_window_get_framebuffer_size(VALUE self)
510
+ {
511
+ int width = 0;
512
+ int height = 0;
513
+ glfwGetFramebufferSize(rb_get_window(self), &width, &height);
514
+ return rb_ary_new3(2, INT2FIX(width), INT2FIX(height));
515
+ }
516
+
517
+
518
+
519
+ /* GLFWAPI void glfwIconifyWindow(GLFWwindow* window); */
520
+
521
+ static VALUE rb_window_iconify(VALUE self)
522
+ {
523
+ glfwIconifyWindow(rb_get_window(self));
524
+ return self;
525
+ }
526
+
527
+
528
+
529
+ /* GLFWAPI void glfwRestoreWindow(GLFWwindow* window); */
530
+
531
+ static VALUE rb_window_restore(VALUE self)
532
+ {
533
+ glfwRestoreWindow(rb_get_window(self));
534
+ return self;
535
+ }
536
+
537
+
538
+
539
+ /* GLFWAPI void glfwShowWindow(GLFWwindow* window); */
540
+
541
+ static VALUE rb_window_show(VALUE self)
542
+ {
543
+ glfwShowWindow(rb_get_window(self));
544
+ return self;
545
+ }
546
+
547
+
548
+
549
+ /* GLFWAPI void glfwHideWindow(GLFWwindow* window); */
550
+
551
+ static VALUE rb_window_hide(VALUE self)
552
+ {
553
+ glfwHideWindow(rb_get_window(self));
554
+ return self;
555
+ }
556
+
557
+
558
+
559
+ /* GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window); */
560
+
561
+ static VALUE rb_window_get_monitor(VALUE self)
562
+ {
563
+ GLFWmonitor *monitor = glfwGetWindowMonitor(rb_get_window(self));
564
+ VALUE rb_monitor = Data_Wrap_Struct(s_glfw_monitor_klass, 0, 0, monitor);
565
+ rb_obj_call_init(rb_monitor, 0, 0);
566
+ return rb_monitor;
567
+ }
568
+
569
+
570
+
571
+ /* GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib); */
572
+
573
+
574
+
575
+
576
+
577
+ /* GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun cbfun); */
578
+
579
+ static void rb_window_window_position_callback(GLFWwindow *window, int x, int y)
580
+ {
581
+ VALUE rb_window = rb_lookup_window(window);
582
+ VALUE rb_func = rb_ivar_get(rb_window, rb_intern(kRB_IVAR_WINDOW_POSITION_CALLBACK));
583
+ rb_funcall(rb_func, rb_intern("call"), 3, rb_window, INT2FIX(x), INT2FIX(y));
584
+ }
585
+
586
+ RB_ENABLE_CALLBACK_DEF(rb_window_set_window_position_callback, rb_window_window_position_callback, glfwSetWindowPosCallback);
587
+
588
+
589
+
590
+
591
+ /* GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun cbfun); */
592
+
593
+ static void rb_window_window_size_callback(GLFWwindow *window, int width, int height)
594
+ {
595
+ VALUE rb_window = rb_lookup_window(window);
596
+ VALUE rb_func = rb_ivar_get(rb_window, rb_intern(kRB_IVAR_WINDOW_SIZE_CALLBACK));
597
+ rb_funcall(rb_func, rb_intern("call"), 3, rb_window, INT2FIX(width), INT2FIX(height));
598
+ }
599
+
600
+ RB_ENABLE_CALLBACK_DEF(rb_window_set_window_size_callback, rb_window_window_size_callback, glfwSetWindowSizeCallback);
601
+
602
+
603
+
604
+ /* GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun cbfun); */
605
+
606
+ static void rb_window_close_callback(GLFWwindow *window)
607
+ {
608
+ VALUE rb_window = rb_lookup_window(window);
609
+ VALUE rb_func = rb_ivar_get(rb_window, rb_intern(kRB_IVAR_WINDOW_CLOSE_CALLBACK));
610
+ rb_funcall(rb_func, rb_intern("call"), 1, rb_window);
611
+ }
612
+
613
+ RB_ENABLE_CALLBACK_DEF(rb_window_set_close_callback, rb_window_close_callback, glfwSetWindowCloseCallback);
614
+
615
+
616
+
617
+
618
+ /* GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun cbfun); */
619
+
620
+ static void rb_window_refresh_callback(GLFWwindow *window)
621
+ {
622
+ VALUE rb_window = rb_lookup_window(window);
623
+ VALUE rb_func = rb_ivar_get(rb_window, rb_intern(kRB_IVAR_WINDOW_REFRESH_CALLBACK));
624
+ rb_funcall(rb_func, rb_intern("call"), 1, rb_window);
625
+ }
626
+
627
+ RB_ENABLE_CALLBACK_DEF(rb_window_set_refresh_callback, rb_window_refresh_callback, glfwSetWindowRefreshCallback);
628
+
629
+
630
+
631
+ /* GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun cbfun); */
632
+
633
+ static void rb_window_focus_callback(GLFWwindow *window, int focused)
634
+ {
635
+ VALUE rb_window = rb_lookup_window(window);
636
+ VALUE rb_func = rb_ivar_get(rb_window, rb_intern(kRB_IVAR_WINDOW_FOCUS_CALLBACK));
637
+ rb_funcall(rb_func, rb_intern("call"), 2, rb_window, focused ? Qtrue : Qfalse);
638
+ }
639
+
640
+ RB_ENABLE_CALLBACK_DEF(rb_window_set_focus_callback, rb_window_focus_callback, glfwSetWindowFocusCallback);
641
+
642
+
643
+
644
+ /* GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun cbfun); */
645
+
646
+ static void rb_window_iconify_callback(GLFWwindow *window, int iconified)
647
+ {
648
+ VALUE rb_window = rb_lookup_window(window);
649
+ VALUE rb_func = rb_ivar_get(rb_window, rb_intern(kRB_IVAR_WINDOW_ICONIFY_CALLBACK));
650
+ rb_funcall(rb_func, rb_intern("call"), 2, rb_window, iconified ? Qtrue : Qfalse);
651
+ }
652
+
653
+ RB_ENABLE_CALLBACK_DEF(rb_window_set_iconify_callback, rb_window_iconify_callback, glfwSetWindowIconifyCallback);
654
+
655
+
656
+
657
+ /* GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun) */
658
+
659
+
660
+ static void rb_window_fbsize_callback(GLFWwindow *window, int width, int height)
661
+ {
662
+ VALUE rb_window = rb_lookup_window(window);
663
+ VALUE rb_func = rb_ivar_get(rb_window, rb_intern(kRB_IVAR_WINDOW_FRAMEBUFFER_SIZE_CALLBACK));
664
+ rb_funcall(rb_func, rb_intern("call"), 3, rb_window, INT2FIX(width), INT2FIX(height));
665
+ }
666
+
667
+ RB_ENABLE_CALLBACK_DEF(rb_window_set_fbsize_callback, rb_window_fbsize_callback, glfwSetFramebufferSizeCallback);
668
+
669
+
670
+
671
+ /* GLFWAPI void glfwPollEvents(void); */
672
+
673
+ static VALUE rb_glfw_poll_events(VALUE self)
674
+ {
675
+ glfwPollEvents();
676
+ return self;
677
+ }
678
+
679
+
680
+
681
+ /* GLFWAPI void glfwWaitEvents(void); */
682
+
683
+ static VALUE rb_glfw_wait_events(VALUE self)
684
+ {
685
+ glfwWaitEvents();
686
+ return self;
687
+ }
688
+
689
+
690
+
691
+ /* GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode); */
692
+
693
+ static VALUE rb_window_get_input_mode(VALUE self, VALUE mode)
694
+ {
695
+ return INT2FIX(glfwGetInputMode(rb_get_window(self), NUM2INT(mode)));
696
+ }
697
+
698
+
699
+
700
+ /* GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value); */
701
+
702
+ static VALUE rb_window_set_input_mode(VALUE self, VALUE mode, VALUE value)
703
+ {
704
+ glfwSetInputMode(rb_get_window(self), NUM2INT(mode), NUM2INT(value));
705
+ return self;
706
+ }
707
+
708
+
709
+
710
+ /* GLFWAPI int glfwGetKey(GLFWwindow* window, int key); */
711
+
712
+ static VALUE rb_window_get_key(VALUE self, VALUE key)
713
+ {
714
+ return INT2FIX(glfwGetKey(rb_get_window(self), NUM2INT(key)));
715
+ }
716
+
717
+
718
+
719
+ /* GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button); */
720
+
721
+ static VALUE rb_window_get_mouse_button(VALUE self, VALUE button)
722
+ {
723
+ return INT2FIX(glfwGetMouseButton(rb_get_window(self), NUM2INT(button)));
724
+ }
725
+
726
+
727
+
728
+ /* GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos); */
729
+
730
+ static VALUE rb_window_get_cursor_pos(VALUE self)
731
+ {
732
+ double xpos = 0;
733
+ double ypos = 0;
734
+ glfwGetCursorPos(rb_get_window(self), &xpos, &ypos);
735
+ return rb_ary_new3(2, rb_float_new(xpos), rb_float_new(ypos));
736
+ }
737
+
738
+
739
+
740
+ /* GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos); */
741
+
742
+ static VALUE rb_window_set_cursor_pos(VALUE self, VALUE x, VALUE y)
743
+ {
744
+ glfwSetCursorPos(rb_get_window(self), NUM2DBL(x), NUM2DBL(y));
745
+ return self;
746
+ }
747
+
748
+
749
+
750
+ /* GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun); */
751
+
752
+ static void rb_window_key_callback(GLFWwindow *window, int key, int scancode, int action, int mods)
753
+ {
754
+ VALUE rb_window = rb_lookup_window(window);
755
+ VALUE rb_func = rb_ivar_get(rb_window, rb_intern(kRB_IVAR_WINDOW_KEY_CALLBACK));
756
+ rb_funcall(rb_func, rb_intern("call"), 5, rb_window, INT2FIX(key), INT2FIX(scancode), INT2FIX(action), INT2FIX(mods));
757
+ }
758
+
759
+ RB_ENABLE_CALLBACK_DEF(rb_window_set_key_callback, rb_window_key_callback, glfwSetKeyCallback);
760
+
761
+
762
+
763
+ /* GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun); */
764
+
765
+ static void rb_window_char_callback(GLFWwindow *window, unsigned int code)
766
+ {
767
+ VALUE rb_window = rb_lookup_window(window);
768
+ VALUE rb_func = rb_ivar_get(rb_window, rb_intern(kRB_IVAR_WINDOW_CHAR_CALLBACK));
769
+ rb_funcall(rb_func, rb_intern("call"), 2, rb_window, UINT2NUM(code));
770
+ }
771
+
772
+ RB_ENABLE_CALLBACK_DEF(rb_window_set_char_callback, rb_window_char_callback, glfwSetCharCallback);
773
+
774
+
775
+
776
+
777
+ /* GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun); */
778
+
779
+ static void rb_window_mouse_button_callback(GLFWwindow *window, int button, int action, int mods)
780
+ {
781
+ VALUE rb_window = rb_lookup_window(window);
782
+ VALUE rb_func = rb_ivar_get(rb_window, rb_intern(kRB_IVAR_WINDOW_MOUSE_BUTTON_CALLBACK));
783
+ rb_funcall(rb_func, rb_intern("call"), 4, rb_window, INT2FIX(button), INT2FIX(action), INT2FIX(mods));
784
+ }
785
+
786
+ RB_ENABLE_CALLBACK_DEF(rb_window_set_mouse_button_callback, rb_window_mouse_button_callback, glfwSetMouseButtonCallback);
787
+
788
+
789
+
790
+ /* GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun cbfun); */
791
+
792
+ static void rb_window_cursor_position_callback(GLFWwindow *window, double x, double y)
793
+ {
794
+ VALUE rb_window = rb_lookup_window(window);
795
+ VALUE rb_func = rb_ivar_get(rb_window, rb_intern(kRB_IVAR_WINDOW_CURSOR_POSITION_CALLBACK));
796
+ rb_funcall(rb_func, rb_intern("call"), 4, rb_window, rb_float_new(x), rb_float_new(y));
797
+ }
798
+
799
+ RB_ENABLE_CALLBACK_DEF(rb_window_set_cursor_position_callback, rb_window_cursor_position_callback, glfwSetCursorPosCallback);
800
+
801
+
802
+
803
+ /* GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun cbfun); */
804
+
805
+ static void rb_window_cursor_enter_callback(GLFWwindow *window, int entered)
806
+ {
807
+ VALUE rb_window = rb_lookup_window(window);
808
+ VALUE rb_func = rb_ivar_get(rb_window, rb_intern(kRB_IVAR_WINDOW_CURSOR_ENTER_CALLBACK));
809
+ rb_funcall(rb_func, rb_intern("call"), 2, rb_window, entered ? Qtrue : Qfalse);
810
+ }
811
+
812
+ RB_ENABLE_CALLBACK_DEF(rb_window_set_cursor_enter_callback, rb_window_cursor_enter_callback, glfwSetCursorEnterCallback);
813
+
814
+
815
+
816
+ /* GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cbfun); */
817
+
818
+ static void rb_window_scroll_callback(GLFWwindow *window, double x, double y)
819
+ {
820
+ VALUE rb_window = rb_lookup_window(window);
821
+ VALUE rb_func = rb_ivar_get(rb_window, rb_intern(kRB_IVAR_WINDOW_SCROLL_CALLBACK));
822
+ rb_funcall(rb_func, rb_intern("call"), 4, rb_window, rb_float_new(x), rb_float_new(y));
823
+ }
824
+
825
+ RB_ENABLE_CALLBACK_DEF(rb_window_set_scroll_callback, rb_window_scroll_callback, glfwSetScrollCallback);
826
+
827
+
828
+
829
+
830
+ /* GLFWAPI int glfwJoystickPresent(int joy); */
831
+
832
+ static VALUE rb_glfw_joysitck_present(VALUE self, VALUE joystick)
833
+ {
834
+ return glfwJoystickPresent(NUM2INT(joystick)) ? Qtrue : Qfalse;
835
+ }
836
+
837
+
838
+
839
+ /* GLFWAPI const float* glfwGetJoystickAxes(int joy, int* count); */
840
+
841
+ static VALUE rb_glfw_get_joystick_axes(VALUE self, VALUE joystick)
842
+ {
843
+ VALUE rb_axes = Qnil;
844
+ int num_axes = 0;
845
+ const float *axes = glfwGetJoystickAxes(NUM2INT(joystick), &num_axes);
846
+ if (num_axes > 0) {
847
+ rb_axes = rb_ary_new();
848
+ for (; num_axes; --num_axes, ++axes) {
849
+ rb_ary_push(rb_axes, rb_float_new(*axes));
850
+ }
851
+ }
852
+ return rb_axes;
853
+ }
854
+
855
+
856
+
857
+ /* GLFWAPI const unsigned char* glfwGetJoystickButtons(int joy, int* count); */
858
+
859
+ static VALUE rb_glfw_get_joystick_buttons(VALUE self, VALUE joystick)
860
+ {
861
+ VALUE rb_buttons = Qnil;
862
+ int num_buttons = 0;
863
+ const unsigned char *buttons = glfwGetJoystickButtons(NUM2INT(joystick), &num_buttons);
864
+ if (num_buttons > 0) {
865
+ rb_buttons = rb_ary_new();
866
+ for (; num_buttons; --num_buttons, ++buttons) {
867
+ rb_ary_push(rb_buttons, rb_float_new(INT2FIX((int)*buttons)));
868
+ }
869
+ }
870
+ return rb_buttons;
871
+ }
872
+
873
+
874
+
875
+ /* GLFWAPI const char* glfwGetJoystickName(int joy); */
876
+
877
+ static VALUE rb_glfw_get_joystick_name(VALUE self, VALUE joystick)
878
+ {
879
+ const char *joy_name = glfwGetJoystickName(NUM2INT(joystick));
880
+ if (joy_name) {
881
+ return rb_str_new2(joy_name);
882
+ } else {
883
+ return Qnil;
884
+ }
885
+ }
886
+
887
+
888
+
889
+ /* GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string); */
890
+
891
+ static VALUE rb_window_set_clipboard_string(VALUE self, VALUE string)
892
+ {
893
+ glfwSetClipboardString(rb_get_window(self), StringValueCStr(string));
894
+ return string;
895
+ }
896
+
897
+
898
+
899
+ /* GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window); */
900
+
901
+ static VALUE rb_window_get_clipboard_string(VALUE self)
902
+ {
903
+ return rb_str_new2(glfwGetClipboardString(rb_get_window(self)));
904
+ }
905
+
906
+
907
+
908
+ /* GLFWAPI double glfwGetTime(void); */
909
+
910
+ static VALUE rb_glfw_get_time(VALUE self)
911
+ {
912
+ return rb_float_new(glfwGetTime());
913
+ }
914
+
915
+
916
+
917
+ /* GLFWAPI void glfwSetTime(double time); */
918
+
919
+ static VALUE rb_glfw_set_time(VALUE self, VALUE time_)
920
+ {
921
+ glfwSetTime(NUM2DBL(time_));
922
+ return time_;
923
+ }
924
+
925
+
926
+
927
+ /* GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window); */
928
+
929
+ static VALUE rb_window_make_context_current(VALUE self)
930
+ {
931
+ glfwMakeContextCurrent(rb_get_window(self));
932
+ return self;
933
+ }
934
+
935
+
936
+
937
+ /* GLFWAPI GLFWwindow* glfwGetCurrentContext(void); */
938
+
939
+ static VALUE rb_window_get_current_context(VALUE self)
940
+ {
941
+ GLFWwindow *window = glfwGetCurrentContext();
942
+ if (window) {
943
+ return (VALUE)glfwGetWindowUserPointer(window);
944
+ } else {
945
+ return Qnil;
946
+ }
947
+ }
948
+
949
+
950
+
951
+ /* GLFWAPI void glfwSwapBuffers(GLFWwindow* window); */
952
+
953
+ static VALUE rb_window_swap_buffers(VALUE self)
954
+ {
955
+ glfwSwapBuffers(rb_get_window(self));
956
+ return self;
957
+ }
958
+
959
+
960
+
961
+ /* GLFWAPI void glfwSwapInterval(int interval); */
962
+
963
+ static VALUE rb_glfw_swap_interval(VALUE self)
964
+ {
965
+ return self;
966
+ }
967
+
968
+
969
+
970
+ /* GLFWAPI int glfwExtensionSupported(const char* extension); */
971
+
972
+ static VALUE rb_glfw_extension_supported(VALUE self)
973
+ {
974
+ return self;
975
+ }
976
+
977
+
978
+
979
+ void Init_glfw3(void)
980
+ {
981
+ s_glfw_module = rb_define_module("Glfw");
982
+ s_glfw_monitor_klass = rb_define_class_under(s_glfw_module, "Monitor", rb_cObject);
983
+ s_glfw_window_klass = rb_define_class_under(s_glfw_module, "Window", rb_cObject);
984
+ s_glfw_window_internal_klass = rb_define_class_under(s_glfw_window_klass, "InternalWindow", rb_cObject);
985
+ s_glfw_videomode_klass = rb_define_class_under(s_glfw_module, "VideoMode", rb_cObject);
986
+
987
+ /* Glfw::Monitor */
988
+ rb_define_method(s_glfw_monitor_klass, "name", rb_monitor_name, 0);
989
+ rb_define_method(s_glfw_monitor_klass, "position", rb_monitor_position, 0);
990
+ rb_define_method(s_glfw_monitor_klass, "physical_size", rb_monitor_physical_size, 0);
991
+ rb_define_method(s_glfw_monitor_klass, "video_modes", rb_monitor_video_modes, 0);
992
+ rb_define_method(s_glfw_monitor_klass, "video_mode", rb_monitor_video_mode, 0);
993
+ rb_define_method(s_glfw_monitor_klass, "set_gamma", rb_monitor_set_gamma, 1);
994
+
995
+ /* Glfw::VideoMode */
996
+ rb_define_method(s_glfw_videomode_klass, "width", rb_videomode_width, 0);
997
+ rb_define_method(s_glfw_videomode_klass, "height", rb_videomode_height, 0);
998
+ rb_define_method(s_glfw_videomode_klass, "red_bits", rb_videomode_red_bits, 0);
999
+ rb_define_method(s_glfw_videomode_klass, "green_bits", rb_videomode_green_bits, 0);
1000
+ rb_define_method(s_glfw_videomode_klass, "blue_bits", rb_videomode_blue_bits, 0);
1001
+ rb_define_method(s_glfw_videomode_klass, "refresh_rate", rb_videomode_refresh_rate, 0);
1002
+
1003
+ /* Glfw::Window */
1004
+ rb_define_singleton_method(s_glfw_window_klass, "new", rb_window_new, -1);
1005
+ rb_define_singleton_method(s_glfw_window_klass, "window_hint", rb_window_window_hint, 2);
1006
+ rb_define_singleton_method(s_glfw_window_klass, "default_window_hints", rb_window_default_window_hints, 0);
1007
+ // rb_define_method(s_glfw_window_klass, "initialize", rb_window_init, -1);
1008
+ rb_define_method(s_glfw_window_klass, "destroy", rb_window_destroy, 0);
1009
+ rb_define_method(s_glfw_window_klass, "should_close?", rb_window_should_close, 0);
1010
+ rb_define_method(s_glfw_window_klass, "should_close=", rb_window_set_should_close, 1);
1011
+ rb_define_method(s_glfw_window_klass, "set_should_close", rb_window_set_should_close, 1);
1012
+ rb_define_method(s_glfw_window_klass, "current_context", rb_window_get_current_context, 0);
1013
+ rb_define_method(s_glfw_window_klass, "make_context_current", rb_window_make_context_current, 0);
1014
+ rb_define_method(s_glfw_window_klass, "swap_buffers", rb_window_swap_buffers, 0);
1015
+ rb_define_method(s_glfw_window_klass, "title=", rb_window_set_title, 1);
1016
+ rb_define_method(s_glfw_window_klass, "position", rb_window_get_position, 0);
1017
+ rb_define_method(s_glfw_window_klass, "move", rb_window_set_position, 2);
1018
+ rb_define_method(s_glfw_window_klass, "size", rb_window_get_size, 0);
1019
+ rb_define_method(s_glfw_window_klass, "resize", rb_window_set_size, 2);
1020
+ rb_define_method(s_glfw_window_klass, "framebuffer_size", rb_window_get_framebuffer_size, 0);
1021
+ rb_define_method(s_glfw_window_klass, "iconify", rb_window_iconify, 0);
1022
+ rb_define_method(s_glfw_window_klass, "restore", rb_window_restore, 0);
1023
+ rb_define_method(s_glfw_window_klass, "show", rb_window_show, 0);
1024
+ rb_define_method(s_glfw_window_klass, "hide", rb_window_hide, 0);
1025
+ rb_define_method(s_glfw_window_klass, "monitor", rb_window_get_monitor, 0);
1026
+ rb_define_method(s_glfw_window_klass, "set_window_position_callback__", rb_window_set_window_position_callback, 1);
1027
+ rb_define_method(s_glfw_window_klass, "set_window_size_callback__", rb_window_set_window_size_callback, 1);
1028
+ rb_define_method(s_glfw_window_klass, "set_close_callback__", rb_window_set_close_callback, 1);
1029
+ rb_define_method(s_glfw_window_klass, "set_refresh_callback__", rb_window_set_refresh_callback, 1);
1030
+ rb_define_method(s_glfw_window_klass, "set_focus_callback__", rb_window_set_focus_callback, 1);
1031
+ rb_define_method(s_glfw_window_klass, "set_iconify_callback__", rb_window_set_iconify_callback, 1);
1032
+ rb_define_method(s_glfw_window_klass, "set_fbsize_callback__", rb_window_set_fbsize_callback, 1);
1033
+ rb_define_method(s_glfw_window_klass, "get_input_mode", rb_window_get_input_mode, 1);
1034
+ rb_define_method(s_glfw_window_klass, "set_input_mode", rb_window_set_input_mode, 2);
1035
+ rb_define_method(s_glfw_window_klass, "key", rb_window_get_key, 1);
1036
+ rb_define_method(s_glfw_window_klass, "mouse_button", rb_window_get_mouse_button, 1);
1037
+ rb_define_method(s_glfw_window_klass, "cursor_pos", rb_window_get_cursor_pos, 0);
1038
+ rb_define_method(s_glfw_window_klass, "set_cursor_pos", rb_window_set_cursor_pos, 2);
1039
+ rb_define_method(s_glfw_window_klass, "set_key_callback__", rb_window_set_key_callback, 1);
1040
+ rb_define_method(s_glfw_window_klass, "set_char_callback__", rb_window_set_char_callback, 1);
1041
+ rb_define_method(s_glfw_window_klass, "set_mouse_button_callback__", rb_window_set_mouse_button_callback, 1);
1042
+ rb_define_method(s_glfw_window_klass, "set_cursor_position_callback__", rb_window_set_cursor_position_callback, 1);
1043
+ rb_define_method(s_glfw_window_klass, "set_cursor_enter_callback__", rb_window_set_cursor_enter_callback, 1);
1044
+ rb_define_method(s_glfw_window_klass, "set_scroll_callback__", rb_window_set_scroll_callback, 1);
1045
+ rb_define_method(s_glfw_window_klass, "clipboard_string=", rb_window_set_clipboard_string, 1);
1046
+ rb_define_method(s_glfw_window_klass, "clipboard_string", rb_window_get_clipboard_string, 0);
1047
+ rb_cvar_set(s_glfw_window_klass, rb_intern(kRB_CVAR_WINDOW_WINDOWS), rb_hash_new());
1048
+
1049
+ /* Glfw */
1050
+ rb_cvar_set(s_glfw_module, rb_intern(kRB_CVAR_GLFW_ERROR_CALLBACK), Qnil);
1051
+ rb_cvar_set(s_glfw_module, rb_intern(kRB_CVAR_GLFW_MONITOR_CALLBACK), Qnil);
1052
+ rb_define_singleton_method(s_glfw_module, "version", rb_glfw_version, 0);
1053
+ rb_define_singleton_method(s_glfw_module, "terminate", rb_glfw_terminate, 0);
1054
+ rb_define_singleton_method(s_glfw_module, "init", rb_glfw_init, 0);
1055
+ rb_define_singleton_method(s_glfw_module, "monitors", rb_glfw_get_monitors, 0);
1056
+ rb_define_singleton_method(s_glfw_module, "primary_monitor", rb_glfw_get_primary_monitor, 0);
1057
+ rb_define_singleton_method(s_glfw_module, "poll_events", rb_glfw_poll_events, 0);
1058
+ rb_define_singleton_method(s_glfw_module, "wait_events", rb_glfw_wait_events, 0);
1059
+ rb_define_singleton_method(s_glfw_module, "joysitck_present", rb_glfw_joysitck_present, 1);
1060
+ rb_define_singleton_method(s_glfw_module, "joystick_axes", rb_glfw_get_joystick_axes, 1);
1061
+ rb_define_singleton_method(s_glfw_module, "joystick_buttons", rb_glfw_get_joystick_buttons, 1);
1062
+ rb_define_singleton_method(s_glfw_module, "joystick_name", rb_glfw_get_joystick_name, 1);
1063
+ rb_define_singleton_method(s_glfw_module, "time", rb_glfw_get_time, 0);
1064
+ rb_define_singleton_method(s_glfw_module, "time=", rb_glfw_set_time, 1);
1065
+ rb_define_singleton_method(s_glfw_module, "swap_interval=", rb_glfw_swap_interval, 1);
1066
+ rb_define_singleton_method(s_glfw_module, "extension_supported?", rb_glfw_extension_supported, 1);
1067
+
1068
+ // DEFINE ALL THE THINGS
1069
+ rb_const_set(s_glfw_module, rb_intern("VERSION_MAJOR"), INT2FIX(GLFW_VERSION_MAJOR));
1070
+ rb_const_set(s_glfw_module, rb_intern("VERSION_MINOR"), INT2FIX(GLFW_VERSION_MINOR));
1071
+ rb_const_set(s_glfw_module, rb_intern("VERSION_REVISION"), INT2FIX(GLFW_VERSION_REVISION));
1072
+ rb_const_set(s_glfw_module, rb_intern("RELEASE"), INT2FIX(GLFW_RELEASE));
1073
+ rb_const_set(s_glfw_module, rb_intern("PRESS"), INT2FIX(GLFW_PRESS));
1074
+ rb_const_set(s_glfw_module, rb_intern("REPEAT"), INT2FIX(GLFW_REPEAT));
1075
+ rb_const_set(s_glfw_module, rb_intern("KEY_UNKNOWN"), INT2FIX(GLFW_KEY_UNKNOWN));
1076
+ rb_const_set(s_glfw_module, rb_intern("KEY_SPACE"), INT2FIX(GLFW_KEY_SPACE));
1077
+ rb_const_set(s_glfw_module, rb_intern("KEY_APOSTROPHE"), INT2FIX(GLFW_KEY_APOSTROPHE));
1078
+ rb_const_set(s_glfw_module, rb_intern("KEY_COMMA"), INT2FIX(GLFW_KEY_COMMA));
1079
+ rb_const_set(s_glfw_module, rb_intern("KEY_MINUS"), INT2FIX(GLFW_KEY_MINUS));
1080
+ rb_const_set(s_glfw_module, rb_intern("KEY_PERIOD"), INT2FIX(GLFW_KEY_PERIOD));
1081
+ rb_const_set(s_glfw_module, rb_intern("KEY_SLASH"), INT2FIX(GLFW_KEY_SLASH));
1082
+ rb_const_set(s_glfw_module, rb_intern("KEY_0"), INT2FIX(GLFW_KEY_0));
1083
+ rb_const_set(s_glfw_module, rb_intern("KEY_1"), INT2FIX(GLFW_KEY_1));
1084
+ rb_const_set(s_glfw_module, rb_intern("KEY_2"), INT2FIX(GLFW_KEY_2));
1085
+ rb_const_set(s_glfw_module, rb_intern("KEY_3"), INT2FIX(GLFW_KEY_3));
1086
+ rb_const_set(s_glfw_module, rb_intern("KEY_4"), INT2FIX(GLFW_KEY_4));
1087
+ rb_const_set(s_glfw_module, rb_intern("KEY_5"), INT2FIX(GLFW_KEY_5));
1088
+ rb_const_set(s_glfw_module, rb_intern("KEY_6"), INT2FIX(GLFW_KEY_6));
1089
+ rb_const_set(s_glfw_module, rb_intern("KEY_7"), INT2FIX(GLFW_KEY_7));
1090
+ rb_const_set(s_glfw_module, rb_intern("KEY_8"), INT2FIX(GLFW_KEY_8));
1091
+ rb_const_set(s_glfw_module, rb_intern("KEY_9"), INT2FIX(GLFW_KEY_9));
1092
+ rb_const_set(s_glfw_module, rb_intern("KEY_SEMICOLON"), INT2FIX(GLFW_KEY_SEMICOLON));
1093
+ rb_const_set(s_glfw_module, rb_intern("KEY_EQUAL"), INT2FIX(GLFW_KEY_EQUAL));
1094
+ rb_const_set(s_glfw_module, rb_intern("KEY_A"), INT2FIX(GLFW_KEY_A));
1095
+ rb_const_set(s_glfw_module, rb_intern("KEY_B"), INT2FIX(GLFW_KEY_B));
1096
+ rb_const_set(s_glfw_module, rb_intern("KEY_C"), INT2FIX(GLFW_KEY_C));
1097
+ rb_const_set(s_glfw_module, rb_intern("KEY_D"), INT2FIX(GLFW_KEY_D));
1098
+ rb_const_set(s_glfw_module, rb_intern("KEY_E"), INT2FIX(GLFW_KEY_E));
1099
+ rb_const_set(s_glfw_module, rb_intern("KEY_F"), INT2FIX(GLFW_KEY_F));
1100
+ rb_const_set(s_glfw_module, rb_intern("KEY_G"), INT2FIX(GLFW_KEY_G));
1101
+ rb_const_set(s_glfw_module, rb_intern("KEY_H"), INT2FIX(GLFW_KEY_H));
1102
+ rb_const_set(s_glfw_module, rb_intern("KEY_I"), INT2FIX(GLFW_KEY_I));
1103
+ rb_const_set(s_glfw_module, rb_intern("KEY_J"), INT2FIX(GLFW_KEY_J));
1104
+ rb_const_set(s_glfw_module, rb_intern("KEY_K"), INT2FIX(GLFW_KEY_K));
1105
+ rb_const_set(s_glfw_module, rb_intern("KEY_L"), INT2FIX(GLFW_KEY_L));
1106
+ rb_const_set(s_glfw_module, rb_intern("KEY_M"), INT2FIX(GLFW_KEY_M));
1107
+ rb_const_set(s_glfw_module, rb_intern("KEY_N"), INT2FIX(GLFW_KEY_N));
1108
+ rb_const_set(s_glfw_module, rb_intern("KEY_O"), INT2FIX(GLFW_KEY_O));
1109
+ rb_const_set(s_glfw_module, rb_intern("KEY_P"), INT2FIX(GLFW_KEY_P));
1110
+ rb_const_set(s_glfw_module, rb_intern("KEY_Q"), INT2FIX(GLFW_KEY_Q));
1111
+ rb_const_set(s_glfw_module, rb_intern("KEY_R"), INT2FIX(GLFW_KEY_R));
1112
+ rb_const_set(s_glfw_module, rb_intern("KEY_S"), INT2FIX(GLFW_KEY_S));
1113
+ rb_const_set(s_glfw_module, rb_intern("KEY_T"), INT2FIX(GLFW_KEY_T));
1114
+ rb_const_set(s_glfw_module, rb_intern("KEY_U"), INT2FIX(GLFW_KEY_U));
1115
+ rb_const_set(s_glfw_module, rb_intern("KEY_V"), INT2FIX(GLFW_KEY_V));
1116
+ rb_const_set(s_glfw_module, rb_intern("KEY_W"), INT2FIX(GLFW_KEY_W));
1117
+ rb_const_set(s_glfw_module, rb_intern("KEY_X"), INT2FIX(GLFW_KEY_X));
1118
+ rb_const_set(s_glfw_module, rb_intern("KEY_Y"), INT2FIX(GLFW_KEY_Y));
1119
+ rb_const_set(s_glfw_module, rb_intern("KEY_Z"), INT2FIX(GLFW_KEY_Z));
1120
+ rb_const_set(s_glfw_module, rb_intern("KEY_LEFT_BRACKET"), INT2FIX(GLFW_KEY_LEFT_BRACKET));
1121
+ rb_const_set(s_glfw_module, rb_intern("KEY_BACKSLASH"), INT2FIX(GLFW_KEY_BACKSLASH));
1122
+ rb_const_set(s_glfw_module, rb_intern("KEY_RIGHT_BRACKET"), INT2FIX(GLFW_KEY_RIGHT_BRACKET));
1123
+ rb_const_set(s_glfw_module, rb_intern("KEY_GRAVE_ACCENT"), INT2FIX(GLFW_KEY_GRAVE_ACCENT));
1124
+ rb_const_set(s_glfw_module, rb_intern("KEY_WORLD_1"), INT2FIX(GLFW_KEY_WORLD_1));
1125
+ rb_const_set(s_glfw_module, rb_intern("KEY_WORLD_2"), INT2FIX(GLFW_KEY_WORLD_2));
1126
+ rb_const_set(s_glfw_module, rb_intern("KEY_ESCAPE"), INT2FIX(GLFW_KEY_ESCAPE));
1127
+ rb_const_set(s_glfw_module, rb_intern("KEY_ENTER"), INT2FIX(GLFW_KEY_ENTER));
1128
+ rb_const_set(s_glfw_module, rb_intern("KEY_TAB"), INT2FIX(GLFW_KEY_TAB));
1129
+ rb_const_set(s_glfw_module, rb_intern("KEY_BACKSPACE"), INT2FIX(GLFW_KEY_BACKSPACE));
1130
+ rb_const_set(s_glfw_module, rb_intern("KEY_INSERT"), INT2FIX(GLFW_KEY_INSERT));
1131
+ rb_const_set(s_glfw_module, rb_intern("KEY_DELETE"), INT2FIX(GLFW_KEY_DELETE));
1132
+ rb_const_set(s_glfw_module, rb_intern("KEY_RIGHT"), INT2FIX(GLFW_KEY_RIGHT));
1133
+ rb_const_set(s_glfw_module, rb_intern("KEY_LEFT"), INT2FIX(GLFW_KEY_LEFT));
1134
+ rb_const_set(s_glfw_module, rb_intern("KEY_DOWN"), INT2FIX(GLFW_KEY_DOWN));
1135
+ rb_const_set(s_glfw_module, rb_intern("KEY_UP"), INT2FIX(GLFW_KEY_UP));
1136
+ rb_const_set(s_glfw_module, rb_intern("KEY_PAGE_UP"), INT2FIX(GLFW_KEY_PAGE_UP));
1137
+ rb_const_set(s_glfw_module, rb_intern("KEY_PAGE_DOWN"), INT2FIX(GLFW_KEY_PAGE_DOWN));
1138
+ rb_const_set(s_glfw_module, rb_intern("KEY_HOME"), INT2FIX(GLFW_KEY_HOME));
1139
+ rb_const_set(s_glfw_module, rb_intern("KEY_END"), INT2FIX(GLFW_KEY_END));
1140
+ rb_const_set(s_glfw_module, rb_intern("KEY_CAPS_LOCK"), INT2FIX(GLFW_KEY_CAPS_LOCK));
1141
+ rb_const_set(s_glfw_module, rb_intern("KEY_SCROLL_LOCK"), INT2FIX(GLFW_KEY_SCROLL_LOCK));
1142
+ rb_const_set(s_glfw_module, rb_intern("KEY_NUM_LOCK"), INT2FIX(GLFW_KEY_NUM_LOCK));
1143
+ rb_const_set(s_glfw_module, rb_intern("KEY_PRINT_SCREEN"), INT2FIX(GLFW_KEY_PRINT_SCREEN));
1144
+ rb_const_set(s_glfw_module, rb_intern("KEY_PAUSE"), INT2FIX(GLFW_KEY_PAUSE));
1145
+ rb_const_set(s_glfw_module, rb_intern("KEY_F1"), INT2FIX(GLFW_KEY_F1));
1146
+ rb_const_set(s_glfw_module, rb_intern("KEY_F2"), INT2FIX(GLFW_KEY_F2));
1147
+ rb_const_set(s_glfw_module, rb_intern("KEY_F3"), INT2FIX(GLFW_KEY_F3));
1148
+ rb_const_set(s_glfw_module, rb_intern("KEY_F4"), INT2FIX(GLFW_KEY_F4));
1149
+ rb_const_set(s_glfw_module, rb_intern("KEY_F5"), INT2FIX(GLFW_KEY_F5));
1150
+ rb_const_set(s_glfw_module, rb_intern("KEY_F6"), INT2FIX(GLFW_KEY_F6));
1151
+ rb_const_set(s_glfw_module, rb_intern("KEY_F7"), INT2FIX(GLFW_KEY_F7));
1152
+ rb_const_set(s_glfw_module, rb_intern("KEY_F8"), INT2FIX(GLFW_KEY_F8));
1153
+ rb_const_set(s_glfw_module, rb_intern("KEY_F9"), INT2FIX(GLFW_KEY_F9));
1154
+ rb_const_set(s_glfw_module, rb_intern("KEY_F10"), INT2FIX(GLFW_KEY_F10));
1155
+ rb_const_set(s_glfw_module, rb_intern("KEY_F11"), INT2FIX(GLFW_KEY_F11));
1156
+ rb_const_set(s_glfw_module, rb_intern("KEY_F12"), INT2FIX(GLFW_KEY_F12));
1157
+ rb_const_set(s_glfw_module, rb_intern("KEY_F13"), INT2FIX(GLFW_KEY_F13));
1158
+ rb_const_set(s_glfw_module, rb_intern("KEY_F14"), INT2FIX(GLFW_KEY_F14));
1159
+ rb_const_set(s_glfw_module, rb_intern("KEY_F15"), INT2FIX(GLFW_KEY_F15));
1160
+ rb_const_set(s_glfw_module, rb_intern("KEY_F16"), INT2FIX(GLFW_KEY_F16));
1161
+ rb_const_set(s_glfw_module, rb_intern("KEY_F17"), INT2FIX(GLFW_KEY_F17));
1162
+ rb_const_set(s_glfw_module, rb_intern("KEY_F18"), INT2FIX(GLFW_KEY_F18));
1163
+ rb_const_set(s_glfw_module, rb_intern("KEY_F19"), INT2FIX(GLFW_KEY_F19));
1164
+ rb_const_set(s_glfw_module, rb_intern("KEY_F20"), INT2FIX(GLFW_KEY_F20));
1165
+ rb_const_set(s_glfw_module, rb_intern("KEY_F21"), INT2FIX(GLFW_KEY_F21));
1166
+ rb_const_set(s_glfw_module, rb_intern("KEY_F22"), INT2FIX(GLFW_KEY_F22));
1167
+ rb_const_set(s_glfw_module, rb_intern("KEY_F23"), INT2FIX(GLFW_KEY_F23));
1168
+ rb_const_set(s_glfw_module, rb_intern("KEY_F24"), INT2FIX(GLFW_KEY_F24));
1169
+ rb_const_set(s_glfw_module, rb_intern("KEY_F25"), INT2FIX(GLFW_KEY_F25));
1170
+ rb_const_set(s_glfw_module, rb_intern("KEY_KP_0"), INT2FIX(GLFW_KEY_KP_0));
1171
+ rb_const_set(s_glfw_module, rb_intern("KEY_KP_1"), INT2FIX(GLFW_KEY_KP_1));
1172
+ rb_const_set(s_glfw_module, rb_intern("KEY_KP_2"), INT2FIX(GLFW_KEY_KP_2));
1173
+ rb_const_set(s_glfw_module, rb_intern("KEY_KP_3"), INT2FIX(GLFW_KEY_KP_3));
1174
+ rb_const_set(s_glfw_module, rb_intern("KEY_KP_4"), INT2FIX(GLFW_KEY_KP_4));
1175
+ rb_const_set(s_glfw_module, rb_intern("KEY_KP_5"), INT2FIX(GLFW_KEY_KP_5));
1176
+ rb_const_set(s_glfw_module, rb_intern("KEY_KP_6"), INT2FIX(GLFW_KEY_KP_6));
1177
+ rb_const_set(s_glfw_module, rb_intern("KEY_KP_7"), INT2FIX(GLFW_KEY_KP_7));
1178
+ rb_const_set(s_glfw_module, rb_intern("KEY_KP_8"), INT2FIX(GLFW_KEY_KP_8));
1179
+ rb_const_set(s_glfw_module, rb_intern("KEY_KP_9"), INT2FIX(GLFW_KEY_KP_9));
1180
+ rb_const_set(s_glfw_module, rb_intern("KEY_KP_DECIMAL"), INT2FIX(GLFW_KEY_KP_DECIMAL));
1181
+ rb_const_set(s_glfw_module, rb_intern("KEY_KP_DIVIDE"), INT2FIX(GLFW_KEY_KP_DIVIDE));
1182
+ rb_const_set(s_glfw_module, rb_intern("KEY_KP_MULTIPLY"), INT2FIX(GLFW_KEY_KP_MULTIPLY));
1183
+ rb_const_set(s_glfw_module, rb_intern("KEY_KP_SUBTRACT"), INT2FIX(GLFW_KEY_KP_SUBTRACT));
1184
+ rb_const_set(s_glfw_module, rb_intern("KEY_KP_ADD"), INT2FIX(GLFW_KEY_KP_ADD));
1185
+ rb_const_set(s_glfw_module, rb_intern("KEY_KP_ENTER"), INT2FIX(GLFW_KEY_KP_ENTER));
1186
+ rb_const_set(s_glfw_module, rb_intern("KEY_KP_EQUAL"), INT2FIX(GLFW_KEY_KP_EQUAL));
1187
+ rb_const_set(s_glfw_module, rb_intern("KEY_LEFT_SHIFT"), INT2FIX(GLFW_KEY_LEFT_SHIFT));
1188
+ rb_const_set(s_glfw_module, rb_intern("KEY_LEFT_CONTROL"), INT2FIX(GLFW_KEY_LEFT_CONTROL));
1189
+ rb_const_set(s_glfw_module, rb_intern("KEY_LEFT_ALT"), INT2FIX(GLFW_KEY_LEFT_ALT));
1190
+ rb_const_set(s_glfw_module, rb_intern("KEY_LEFT_SUPER"), INT2FIX(GLFW_KEY_LEFT_SUPER));
1191
+ rb_const_set(s_glfw_module, rb_intern("KEY_RIGHT_SHIFT"), INT2FIX(GLFW_KEY_RIGHT_SHIFT));
1192
+ rb_const_set(s_glfw_module, rb_intern("KEY_RIGHT_CONTROL"), INT2FIX(GLFW_KEY_RIGHT_CONTROL));
1193
+ rb_const_set(s_glfw_module, rb_intern("KEY_RIGHT_ALT"), INT2FIX(GLFW_KEY_RIGHT_ALT));
1194
+ rb_const_set(s_glfw_module, rb_intern("KEY_RIGHT_SUPER"), INT2FIX(GLFW_KEY_RIGHT_SUPER));
1195
+ rb_const_set(s_glfw_module, rb_intern("KEY_MENU"), INT2FIX(GLFW_KEY_MENU));
1196
+ rb_const_set(s_glfw_module, rb_intern("KEY_LAST"), INT2FIX(GLFW_KEY_LAST));
1197
+ rb_const_set(s_glfw_module, rb_intern("MOD_SHIFT"), INT2FIX(GLFW_MOD_SHIFT));
1198
+ rb_const_set(s_glfw_module, rb_intern("MOD_CONTROL"), INT2FIX(GLFW_MOD_CONTROL));
1199
+ rb_const_set(s_glfw_module, rb_intern("MOD_ALT"), INT2FIX(GLFW_MOD_ALT));
1200
+ rb_const_set(s_glfw_module, rb_intern("MOD_SUPER"), INT2FIX(GLFW_MOD_SUPER));
1201
+ rb_const_set(s_glfw_module, rb_intern("MOUSE_BUTTON_1"), INT2FIX(GLFW_MOUSE_BUTTON_1));
1202
+ rb_const_set(s_glfw_module, rb_intern("MOUSE_BUTTON_2"), INT2FIX(GLFW_MOUSE_BUTTON_2));
1203
+ rb_const_set(s_glfw_module, rb_intern("MOUSE_BUTTON_3"), INT2FIX(GLFW_MOUSE_BUTTON_3));
1204
+ rb_const_set(s_glfw_module, rb_intern("MOUSE_BUTTON_4"), INT2FIX(GLFW_MOUSE_BUTTON_4));
1205
+ rb_const_set(s_glfw_module, rb_intern("MOUSE_BUTTON_5"), INT2FIX(GLFW_MOUSE_BUTTON_5));
1206
+ rb_const_set(s_glfw_module, rb_intern("MOUSE_BUTTON_6"), INT2FIX(GLFW_MOUSE_BUTTON_6));
1207
+ rb_const_set(s_glfw_module, rb_intern("MOUSE_BUTTON_7"), INT2FIX(GLFW_MOUSE_BUTTON_7));
1208
+ rb_const_set(s_glfw_module, rb_intern("MOUSE_BUTTON_8"), INT2FIX(GLFW_MOUSE_BUTTON_8));
1209
+ rb_const_set(s_glfw_module, rb_intern("MOUSE_BUTTON_LAST"), INT2FIX(GLFW_MOUSE_BUTTON_LAST));
1210
+ rb_const_set(s_glfw_module, rb_intern("MOUSE_BUTTON_LEFT"), INT2FIX(GLFW_MOUSE_BUTTON_LEFT));
1211
+ rb_const_set(s_glfw_module, rb_intern("MOUSE_BUTTON_RIGHT"), INT2FIX(GLFW_MOUSE_BUTTON_RIGHT));
1212
+ rb_const_set(s_glfw_module, rb_intern("MOUSE_BUTTON_MIDDLE"), INT2FIX(GLFW_MOUSE_BUTTON_MIDDLE));
1213
+ rb_const_set(s_glfw_module, rb_intern("JOYSTICK_1"), INT2FIX(GLFW_JOYSTICK_1));
1214
+ rb_const_set(s_glfw_module, rb_intern("JOYSTICK_2"), INT2FIX(GLFW_JOYSTICK_2));
1215
+ rb_const_set(s_glfw_module, rb_intern("JOYSTICK_3"), INT2FIX(GLFW_JOYSTICK_3));
1216
+ rb_const_set(s_glfw_module, rb_intern("JOYSTICK_4"), INT2FIX(GLFW_JOYSTICK_4));
1217
+ rb_const_set(s_glfw_module, rb_intern("JOYSTICK_5"), INT2FIX(GLFW_JOYSTICK_5));
1218
+ rb_const_set(s_glfw_module, rb_intern("JOYSTICK_6"), INT2FIX(GLFW_JOYSTICK_6));
1219
+ rb_const_set(s_glfw_module, rb_intern("JOYSTICK_7"), INT2FIX(GLFW_JOYSTICK_7));
1220
+ rb_const_set(s_glfw_module, rb_intern("JOYSTICK_8"), INT2FIX(GLFW_JOYSTICK_8));
1221
+ rb_const_set(s_glfw_module, rb_intern("JOYSTICK_9"), INT2FIX(GLFW_JOYSTICK_9));
1222
+ rb_const_set(s_glfw_module, rb_intern("JOYSTICK_10"), INT2FIX(GLFW_JOYSTICK_10));
1223
+ rb_const_set(s_glfw_module, rb_intern("JOYSTICK_11"), INT2FIX(GLFW_JOYSTICK_11));
1224
+ rb_const_set(s_glfw_module, rb_intern("JOYSTICK_12"), INT2FIX(GLFW_JOYSTICK_12));
1225
+ rb_const_set(s_glfw_module, rb_intern("JOYSTICK_13"), INT2FIX(GLFW_JOYSTICK_13));
1226
+ rb_const_set(s_glfw_module, rb_intern("JOYSTICK_14"), INT2FIX(GLFW_JOYSTICK_14));
1227
+ rb_const_set(s_glfw_module, rb_intern("JOYSTICK_15"), INT2FIX(GLFW_JOYSTICK_15));
1228
+ rb_const_set(s_glfw_module, rb_intern("JOYSTICK_16"), INT2FIX(GLFW_JOYSTICK_16));
1229
+ rb_const_set(s_glfw_module, rb_intern("JOYSTICK_LAST"), INT2FIX(GLFW_JOYSTICK_LAST));
1230
+ rb_const_set(s_glfw_module, rb_intern("NOT_INITIALIZED"), INT2FIX(GLFW_NOT_INITIALIZED));
1231
+ rb_const_set(s_glfw_module, rb_intern("NO_CURRENT_CONTEXT"), INT2FIX(GLFW_NO_CURRENT_CONTEXT));
1232
+ rb_const_set(s_glfw_module, rb_intern("INVALID_ENUM"), INT2FIX(GLFW_INVALID_ENUM));
1233
+ rb_const_set(s_glfw_module, rb_intern("INVALID_VALUE"), INT2FIX(GLFW_INVALID_VALUE));
1234
+ rb_const_set(s_glfw_module, rb_intern("OUT_OF_MEMORY"), INT2FIX(GLFW_OUT_OF_MEMORY));
1235
+ rb_const_set(s_glfw_module, rb_intern("API_UNAVAILABLE"), INT2FIX(GLFW_API_UNAVAILABLE));
1236
+ rb_const_set(s_glfw_module, rb_intern("VERSION_UNAVAILABLE"), INT2FIX(GLFW_VERSION_UNAVAILABLE));
1237
+ rb_const_set(s_glfw_module, rb_intern("PLATFORM_ERROR"), INT2FIX(GLFW_PLATFORM_ERROR));
1238
+ rb_const_set(s_glfw_module, rb_intern("FORMAT_UNAVAILABLE"), INT2FIX(GLFW_FORMAT_UNAVAILABLE));
1239
+ rb_const_set(s_glfw_module, rb_intern("FOCUSED"), INT2FIX(GLFW_FOCUSED));
1240
+ rb_const_set(s_glfw_module, rb_intern("ICONIFIED"), INT2FIX(GLFW_ICONIFIED));
1241
+ rb_const_set(s_glfw_module, rb_intern("RESIZABLE"), INT2FIX(GLFW_RESIZABLE));
1242
+ rb_const_set(s_glfw_module, rb_intern("VISIBLE"), INT2FIX(GLFW_VISIBLE));
1243
+ rb_const_set(s_glfw_module, rb_intern("DECORATED"), INT2FIX(GLFW_DECORATED));
1244
+ rb_const_set(s_glfw_module, rb_intern("RED_BITS"), INT2FIX(GLFW_RED_BITS));
1245
+ rb_const_set(s_glfw_module, rb_intern("GREEN_BITS"), INT2FIX(GLFW_GREEN_BITS));
1246
+ rb_const_set(s_glfw_module, rb_intern("BLUE_BITS"), INT2FIX(GLFW_BLUE_BITS));
1247
+ rb_const_set(s_glfw_module, rb_intern("ALPHA_BITS"), INT2FIX(GLFW_ALPHA_BITS));
1248
+ rb_const_set(s_glfw_module, rb_intern("DEPTH_BITS"), INT2FIX(GLFW_DEPTH_BITS));
1249
+ rb_const_set(s_glfw_module, rb_intern("STENCIL_BITS"), INT2FIX(GLFW_STENCIL_BITS));
1250
+ rb_const_set(s_glfw_module, rb_intern("ACCUM_RED_BITS"), INT2FIX(GLFW_ACCUM_RED_BITS));
1251
+ rb_const_set(s_glfw_module, rb_intern("ACCUM_GREEN_BITS"), INT2FIX(GLFW_ACCUM_GREEN_BITS));
1252
+ rb_const_set(s_glfw_module, rb_intern("ACCUM_BLUE_BITS"), INT2FIX(GLFW_ACCUM_BLUE_BITS));
1253
+ rb_const_set(s_glfw_module, rb_intern("ACCUM_ALPHA_BITS"), INT2FIX(GLFW_ACCUM_ALPHA_BITS));
1254
+ rb_const_set(s_glfw_module, rb_intern("AUX_BUFFERS"), INT2FIX(GLFW_AUX_BUFFERS));
1255
+ rb_const_set(s_glfw_module, rb_intern("STEREO"), INT2FIX(GLFW_STEREO));
1256
+ rb_const_set(s_glfw_module, rb_intern("SAMPLES"), INT2FIX(GLFW_SAMPLES));
1257
+ rb_const_set(s_glfw_module, rb_intern("SRGB_CAPABLE"), INT2FIX(GLFW_SRGB_CAPABLE));
1258
+ rb_const_set(s_glfw_module, rb_intern("REFRESH_RATE"), INT2FIX(GLFW_REFRESH_RATE));
1259
+ rb_const_set(s_glfw_module, rb_intern("CLIENT_API"), INT2FIX(GLFW_CLIENT_API));
1260
+ rb_const_set(s_glfw_module, rb_intern("CONTEXT_VERSION_MAJOR"), INT2FIX(GLFW_CONTEXT_VERSION_MAJOR));
1261
+ rb_const_set(s_glfw_module, rb_intern("CONTEXT_VERSION_MINOR"), INT2FIX(GLFW_CONTEXT_VERSION_MINOR));
1262
+ rb_const_set(s_glfw_module, rb_intern("CONTEXT_REVISION"), INT2FIX(GLFW_CONTEXT_REVISION));
1263
+ rb_const_set(s_glfw_module, rb_intern("CONTEXT_ROBUSTNESS"), INT2FIX(GLFW_CONTEXT_ROBUSTNESS));
1264
+ rb_const_set(s_glfw_module, rb_intern("OPENGL_FORWARD_COMPAT"), INT2FIX(GLFW_OPENGL_FORWARD_COMPAT));
1265
+ rb_const_set(s_glfw_module, rb_intern("OPENGL_DEBUG_CONTEXT"), INT2FIX(GLFW_OPENGL_DEBUG_CONTEXT));
1266
+ rb_const_set(s_glfw_module, rb_intern("OPENGL_PROFILE"), INT2FIX(GLFW_OPENGL_PROFILE));
1267
+ rb_const_set(s_glfw_module, rb_intern("OPENGL_API"), INT2FIX(GLFW_OPENGL_API));
1268
+ rb_const_set(s_glfw_module, rb_intern("OPENGL_ES_API"), INT2FIX(GLFW_OPENGL_ES_API));
1269
+ rb_const_set(s_glfw_module, rb_intern("NO_ROBUSTNESS"), INT2FIX(GLFW_NO_ROBUSTNESS));
1270
+ rb_const_set(s_glfw_module, rb_intern("NO_RESET_NOTIFICATION"), INT2FIX(GLFW_NO_RESET_NOTIFICATION));
1271
+ rb_const_set(s_glfw_module, rb_intern("LOSE_CONTEXT_ON_RESET"), INT2FIX(GLFW_LOSE_CONTEXT_ON_RESET));
1272
+ rb_const_set(s_glfw_module, rb_intern("OPENGL_ANY_PROFILE"), INT2FIX(GLFW_OPENGL_ANY_PROFILE));
1273
+ rb_const_set(s_glfw_module, rb_intern("OPENGL_CORE_PROFILE"), INT2FIX(GLFW_OPENGL_CORE_PROFILE));
1274
+ rb_const_set(s_glfw_module, rb_intern("OPENGL_COMPAT_PROFILE"), INT2FIX(GLFW_OPENGL_COMPAT_PROFILE));
1275
+ rb_const_set(s_glfw_module, rb_intern("CURSOR"), INT2FIX(GLFW_CURSOR));
1276
+ rb_const_set(s_glfw_module, rb_intern("STICKY_KEYS"), INT2FIX(GLFW_STICKY_KEYS));
1277
+ rb_const_set(s_glfw_module, rb_intern("STICKY_MOUSE_BUTTONS"), INT2FIX(GLFW_STICKY_MOUSE_BUTTONS));
1278
+ rb_const_set(s_glfw_module, rb_intern("CURSOR_NORMAL"), INT2FIX(GLFW_CURSOR_NORMAL));
1279
+ rb_const_set(s_glfw_module, rb_intern("CURSOR_HIDDEN"), INT2FIX(GLFW_CURSOR_HIDDEN));
1280
+ rb_const_set(s_glfw_module, rb_intern("CURSOR_DISABLED"), INT2FIX(GLFW_CURSOR_DISABLED));
1281
+ rb_const_set(s_glfw_module, rb_intern("CONNECTED"), INT2FIX(GLFW_CONNECTED));
1282
+ rb_const_set(s_glfw_module, rb_intern("DISCONNECTED"), INT2FIX(GLFW_DISCONNECTED));
1283
+
1284
+ glfwSetErrorCallback(rb_glfw_error_callback);
1285
+ }
1286
+