glfw3 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c4fc82c45dd13e3c37d24bb3822a0b0ee252fb3
4
- data.tar.gz: 1a797aad6127b1fc40ec537fbccfbcd70fd0fab3
3
+ metadata.gz: c71879992988bff0b3bd240651241e68c5f6315c
4
+ data.tar.gz: 6de12532188d628f437867a407d7dd0dd26d8921
5
5
  SHA512:
6
- metadata.gz: 6a4feeed03264358cc93577697cdb13bd011de607f78a77650c40309615f740f95beb038c95f7548db3ec4698476d3e31ad366578ad807647fe72a55bc5f5d3d
7
- data.tar.gz: 2c0f4f2095c0d6d15494641daa79fdc131960889256345428d4eb32dfdd365420f7b3537bbbea64bd3ca76796f7a562dd05149505fae6ed20b6e4f5f5409e22f
6
+ metadata.gz: aecf77997284f61fc094da9ae5aa7d89b75ad2f1a474e4ba3fb8e9004a9316298e3b9fa8059639e6c7f5492be5d7fac8e874d7afb08a75e5759dc2f0d6300f13
7
+ data.tar.gz: cec9e493ec9a01b0d45ebb5bb004aa3840340dbbd43edd85c013ddeb484a1f1b1240eedb295f92925818f71f8ca64067bb3f8ac09016158c51c6e1e86da28f50
data/COPYING ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2013, Noel Raymond Cower <ncower@gmail.com>.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
17
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+
24
+ The views and conclusions contained in the software and documentation are those
25
+ of the authors and should not be interpreted as representing official policies,
26
+ either expressed or implied, of the FreeBSD Project.
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ ruby-glfw3
2
+ ==========
3
+
4
+ [GLFW 3] bindings gem for Ruby 2.x.
5
+
6
+ To install the gem, you'll need GLFW 3 built and installed where pkg-config can
7
+ find it. You may also want to grab some [OpenGL bindings] as well.
8
+
9
+ [OpenGL bindings]: https://github.com/nilium/ruby-opengl
10
+ [GLFW 3]: https://github.com/glfw/glfw
11
+
12
+ Once that's taken care of, you can install it simply by building and installing
13
+ the gem, like so:
14
+
15
+ $ gem build glfw3.gemspec
16
+ $ gem install glfw3-0.0.1.gemspec
17
+
18
+ After that, write a quick script to toy with it. For example:
19
+
20
+ require 'glfw3'
21
+ require 'opengl-core'
22
+
23
+ # Initialize GLFW 3
24
+ Glfw.init
25
+
26
+ # Create a window
27
+ window = Glfw::Window.new(800, 600, "Foobar")
28
+
29
+ # Set some callbacks
30
+ window.set_key_callback {
31
+ |window, key, code, action, mods|
32
+ window.should_close = true if key == Glfw::KEY_ESCAPE
33
+ }
34
+
35
+ window.set_close_callback {
36
+ |window|
37
+ window.should_close = true
38
+ }
39
+
40
+ # Make the window's context current
41
+ window.make_context_current
42
+ loop {
43
+ # And do stuff
44
+ Glfw.wait_events
45
+ Gl.glClear(Gl::GL_COLOR_BUFFER_BIT | Gl::GL_DEPTH_BUFFER_BIT)
46
+ window.swap_buffers
47
+ break if window.should_close?
48
+ }
49
+
50
+ # Explicitly destroy the window when done with it.
51
+ window.destroy
52
+
53
+
54
+ License
55
+ -------
56
+
57
+ ruby-glw3 is licensed under a simplified BSD license because it seems the most
58
+ reasonable. If there's a problem with that, let me know.
59
+
60
+ Copyright (c) 2013, Noel Raymond Cower <ncower@gmail.com>.
61
+ All rights reserved.
62
+
63
+ Redistribution and use in source and binary forms, with or without
64
+ modification, are permitted provided that the following conditions are met:
65
+
66
+ 1. Redistributions of source code must retain the above copyright notice, this
67
+ list of conditions and the following disclaimer.
68
+ 2. Redistributions in binary form must reproduce the above copyright notice,
69
+ this list of conditions and the following disclaimer in the documentation
70
+ and/or other materials provided with the distribution.
71
+
72
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
73
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
74
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
75
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
76
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
77
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
78
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
79
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
80
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
81
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
82
+
83
+ The views and conclusions contained in the software and documentation are those
84
+ of the authors and should not be interpreted as representing official policies,
85
+ either expressed or implied, of the FreeBSD Project.
86
+
data/ext/glfw3/glfw3.c CHANGED
@@ -51,8 +51,14 @@ static VALUE NAME (VALUE self, VALUE enabled) \
51
51
  }
52
52
 
53
53
 
54
- /* GLFWAPI int glfwInit(void); */
55
-
54
+ /*
55
+ * Initializes GLFW. Returns true on success, false on failure.
56
+ *
57
+ * call-seq:
58
+ * init -> true or false
59
+ *
60
+ * Wraps glfwInit.
61
+ */
56
62
  static VALUE rb_glfw_init(VALUE self)
57
63
  {
58
64
  (void)self;
@@ -66,8 +72,11 @@ static VALUE rb_glfw_init(VALUE self)
66
72
 
67
73
 
68
74
 
69
- /* GLFWAPI void glfwTerminate(void); */
70
-
75
+ /*
76
+ * Terminates GLFW.
77
+ *
78
+ * Wraps glfwTerminate.
79
+ */
71
80
  static VALUE rb_glfw_terminate(VALUE self)
72
81
  {
73
82
  glfwTerminate();
@@ -76,8 +85,14 @@ static VALUE rb_glfw_terminate(VALUE self)
76
85
 
77
86
 
78
87
 
79
- /* GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev); */
80
-
88
+ /*
89
+ * Returns GLFW's version in an array.
90
+ *
91
+ * call-seq:
92
+ * version -> [major, minor, revision]
93
+ *
94
+ * Wraps glfwGetVersion.
95
+ */
81
96
  static VALUE rb_glfw_version(VALUE self)
82
97
  {
83
98
  int major = 0;
@@ -89,14 +104,10 @@ static VALUE rb_glfw_version(VALUE self)
89
104
 
90
105
 
91
106
 
92
- /* GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun); */
93
-
94
107
  static void rb_glfw_error_callback(int error_code, const char *description)
95
108
  {
96
109
  VALUE lambda = rb_cvar_get(s_glfw_module, rb_intern(kRB_CVAR_GLFW_ERROR_CALLBACK));
97
110
 
98
-
99
-
100
111
  if (RTEST(lambda)) {
101
112
  VALUE rb_description = rb_str_new2(description);
102
113
  VALUE rb_error_code = INT2FIX(error_code);
@@ -110,8 +121,14 @@ static void rb_glfw_error_callback(int error_code, const char *description)
110
121
 
111
122
 
112
123
 
113
- /* GLFWAPI GLFWmonitor** glfwGetMonitors(int* count); */
114
-
124
+ /*
125
+ * Gets an array of all currently connected monitors.
126
+ *
127
+ * call-seq:
128
+ * monitors -> [Glfw::Monitor, ...]
129
+ *
130
+ * Wraps glfwGetMonitors.
131
+ */
115
132
  VALUE rb_glfw_get_monitors(VALUE self)
116
133
  {
117
134
  long monitor_index = 0;
@@ -128,8 +145,14 @@ VALUE rb_glfw_get_monitors(VALUE self)
128
145
 
129
146
 
130
147
 
131
- /* GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void); */
132
-
148
+ /*
149
+ * Gets the primary monitor.
150
+ *
151
+ * call-seq:
152
+ * primary_monitor -> Glfw::Monitor
153
+ *
154
+ * Wraps glfwGetPrimaryMonitor.
155
+ */
133
156
  VALUE rb_glfw_get_primary_monitor(VALUE self)
134
157
  {
135
158
  VALUE monitor = Data_Wrap_Struct(s_glfw_monitor_klass, 0, 0, glfwGetPrimaryMonitor());
@@ -139,8 +162,14 @@ VALUE rb_glfw_get_primary_monitor(VALUE self)
139
162
 
140
163
 
141
164
 
142
- /* GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos); */
143
-
165
+ /*
166
+ * Gets the monitor's position in screen-space.
167
+ *
168
+ * call-seq:
169
+ * position -> [x, y]
170
+ *
171
+ * Wraps glfwGetMonitorPos.
172
+ */
144
173
  VALUE rb_monitor_position(VALUE self)
145
174
  {
146
175
  GLFWmonitor *monitor;
@@ -153,8 +182,14 @@ VALUE rb_monitor_position(VALUE self)
153
182
 
154
183
 
155
184
 
156
- /* GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* width, int* height); */
157
-
185
+ /*
186
+ * Gets the physical size of the monitor.
187
+ *
188
+ * call-seq:
189
+ * physical_size -> [width, height]
190
+ *
191
+ * Wraps glfwGetMonitorPhysicalSize.
192
+ */
158
193
  VALUE rb_monitor_physical_size(VALUE self)
159
194
  {
160
195
  GLFWmonitor *monitor;
@@ -167,9 +202,14 @@ VALUE rb_monitor_physical_size(VALUE self)
167
202
 
168
203
 
169
204
 
170
- /* GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor); */
171
-
172
-
205
+ /*
206
+ * Gets the name of the monitor.
207
+ *
208
+ * call-seq:
209
+ * name -> String
210
+ *
211
+ * Wraps glfwGetMonitorName.
212
+ */
173
213
  VALUE rb_monitor_name(VALUE self)
174
214
  {
175
215
  GLFWmonitor *monitor;
@@ -179,8 +219,6 @@ VALUE rb_monitor_name(VALUE self)
179
219
 
180
220
 
181
221
 
182
- /* GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun); */
183
-
184
222
  static void rb_glfw_monitor_callback(GLFWmonitor *monitor, int message)
185
223
  {
186
224
  VALUE lambda = rb_cvar_get(s_glfw_module, rb_intern(kRB_CVAR_GLFW_MONITOR_CALLBACK));
@@ -193,8 +231,14 @@ static void rb_glfw_monitor_callback(GLFWmonitor *monitor, int message)
193
231
 
194
232
 
195
233
 
196
- /* GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count); */
197
-
234
+ /*
235
+ * The width of the video mode.
236
+ *
237
+ * call-seq:
238
+ * width -> Fixed
239
+ *
240
+ * Wraps GLFWvidmode.width.
241
+ */
198
242
  static VALUE rb_videomode_width(VALUE self)
199
243
  {
200
244
  GLFWvidmode *mode;
@@ -202,6 +246,14 @@ static VALUE rb_videomode_width(VALUE self)
202
246
  return INT2FIX(mode->width);
203
247
  }
204
248
 
249
+ /*
250
+ * The height of the video mode.
251
+ *
252
+ * call-seq:
253
+ * height -> Fixed
254
+ *
255
+ * Wraps GLFWvidmode.height.
256
+ */
205
257
  static VALUE rb_videomode_height(VALUE self)
206
258
  {
207
259
  GLFWvidmode *mode;
@@ -209,6 +261,14 @@ static VALUE rb_videomode_height(VALUE self)
209
261
  return INT2FIX(mode->height);
210
262
  }
211
263
 
264
+ /*
265
+ * The number of red bits in the video mode.
266
+ *
267
+ * call-seq:
268
+ * red_bits -> Fixed
269
+ *
270
+ * Wraps GLFWvidmode.redBits.
271
+ */
212
272
  static VALUE rb_videomode_red_bits(VALUE self)
213
273
  {
214
274
  GLFWvidmode *mode;
@@ -216,6 +276,14 @@ static VALUE rb_videomode_red_bits(VALUE self)
216
276
  return INT2FIX(mode->redBits);
217
277
  }
218
278
 
279
+ /*
280
+ * The number of green bits in the video mode.
281
+ *
282
+ * call-seq:
283
+ * green_bits -> Fixed
284
+ *
285
+ * Wraps GLFWvidmode.greenBits.
286
+ */
219
287
  static VALUE rb_videomode_green_bits(VALUE self)
220
288
  {
221
289
  GLFWvidmode *mode;
@@ -223,6 +291,14 @@ static VALUE rb_videomode_green_bits(VALUE self)
223
291
  return INT2FIX(mode->greenBits);
224
292
  }
225
293
 
294
+ /*
295
+ * The number of blue bits in the video mode.
296
+ *
297
+ * call-seq:
298
+ * blue_bits -> Fixed
299
+ *
300
+ * Wraps GLFWvidmode.blueBits.
301
+ */
226
302
  static VALUE rb_videomode_blue_bits(VALUE self)
227
303
  {
228
304
  GLFWvidmode *mode;
@@ -230,6 +306,14 @@ static VALUE rb_videomode_blue_bits(VALUE self)
230
306
  return INT2FIX(mode->blueBits);
231
307
  }
232
308
 
309
+ /*
310
+ * The video mode's refresh rate.
311
+ *
312
+ * call-seq:
313
+ * refresh_rate -> Fixed
314
+ *
315
+ * Wraps GLFWvidmode.refreshRate.
316
+ */
233
317
  static VALUE rb_videomode_refresh_rate(VALUE self)
234
318
  {
235
319
  GLFWvidmode *mode;
@@ -237,6 +321,16 @@ static VALUE rb_videomode_refresh_rate(VALUE self)
237
321
  return INT2FIX(mode->refreshRate);
238
322
  }
239
323
 
324
+ /*
325
+ * Gets an array of all video modes associated with the monitor, sorted
326
+ * ascending first by color depth and then the video mode's area
327
+ * (width x height).
328
+ *
329
+ * call-seq:
330
+ * video_mode -> [Glfw::VideoMode, ...]
331
+ *
332
+ * Wraps glfwGetVideoModes.
333
+ */
240
334
  static VALUE rb_monitor_video_modes(VALUE self)
241
335
  {
242
336
  GLFWmonitor *monitor;
@@ -257,8 +351,14 @@ static VALUE rb_monitor_video_modes(VALUE self)
257
351
 
258
352
 
259
353
 
260
- /* GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor); */
261
-
354
+ /*
355
+ * Gets the monitor's current video mode.
356
+ *
357
+ * call-seq:
358
+ * video_mode -> Glfw::VideoMode
359
+ *
360
+ * Wraps glfwGetVideoMode.
361
+ */
262
362
  static VALUE rb_monitor_video_mode(VALUE self)
263
363
  {
264
364
  GLFWmonitor *monitor;
@@ -272,8 +372,15 @@ static VALUE rb_monitor_video_mode(VALUE self)
272
372
 
273
373
 
274
374
 
275
- /* GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma); */
276
-
375
+ /*
376
+ * Sets the monitor's gamma ramp to a 256-element ramp generated by the given
377
+ * exponent.
378
+ *
379
+ * call-seq:
380
+ * set_gamma(gamma) -> self
381
+ *
382
+ * Wraps glfwSetGamma.
383
+ */
277
384
  static VALUE rb_monitor_set_gamma(VALUE self, VALUE gamma)
278
385
  {
279
386
  GLFWmonitor *monitor;
@@ -284,20 +391,20 @@ static VALUE rb_monitor_set_gamma(VALUE self, VALUE gamma)
284
391
 
285
392
 
286
393
 
287
- /* GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor); */
288
-
289
394
  #warning "No implementation for glfwGetGammaRamp bindings"
290
-
291
-
292
-
293
- /* GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp); */
294
-
295
395
  #warning "No implementation for glfwSetGammaRamp bindings"
296
396
 
297
397
 
298
398
 
299
- /* GLFWAPI void glfwDefaultWindowHints(void); */
300
-
399
+ /*
400
+ * Sets the window hints to their default values. See GLFW 3 documentation for
401
+ * details on what those values are.
402
+ *
403
+ * call-seq:
404
+ * default_window_hints() -> self
405
+ *
406
+ * Wraps glfwDefaultWindowHints.
407
+ */
301
408
  static VALUE rb_window_default_window_hints(VALUE self)
302
409
  {
303
410
  glfwDefaultWindowHints();
@@ -306,8 +413,14 @@ static VALUE rb_window_default_window_hints(VALUE self)
306
413
 
307
414
 
308
415
 
309
- /* GLFWAPI void glfwWindowHint(int target, int hint); */
310
-
416
+ /*
417
+ * Sets a window hint to the given value.
418
+ *
419
+ * call-seq:
420
+ * window_hint(target, hint) -> self
421
+ *
422
+ * Wraps glfwWindowHint.
423
+ */
311
424
  static VALUE rb_window_window_hint(VALUE self, VALUE target, VALUE hint)
312
425
  {
313
426
  glfwWindowHint(NUM2INT(target), NUM2INT(hint));
@@ -315,14 +428,13 @@ static VALUE rb_window_window_hint(VALUE self, VALUE target, VALUE hint)
315
428
  }
316
429
 
317
430
 
318
-
319
- /* GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, */
320
-
431
+ // Auxiliary function for extracting a Glfw::Window object from a GLFWwindow.
321
432
  static VALUE rb_lookup_window(GLFWwindow *window)
322
433
  {
323
434
  return (VALUE)glfwGetWindowUserPointer(window);
324
435
  }
325
436
 
437
+ // And the opposite of rb_lookup_window
326
438
  static GLFWwindow *rb_get_window(VALUE rb_window)
327
439
  {
328
440
  GLFWwindow *window = NULL;
@@ -336,11 +448,15 @@ static GLFWwindow *rb_get_window(VALUE rb_window)
336
448
  return window;
337
449
  }
338
450
 
339
- // static VALUE rb_window_init(int argc, VALUE *argv, VALUE self)
340
- // {
341
- // return self;
342
- // }
343
-
451
+ /*
452
+ * Creates a new window with the given parameters. If a shared window is
453
+ * provided, the new window will use the context of the shared window.
454
+ *
455
+ * call-seq:
456
+ * new(width, height, title='', monitor=nil, shared_window=nil) -> Glfw::Window
457
+ *
458
+ * Wraps glfwCreateWindow.
459
+ */
344
460
  static VALUE rb_window_new(int argc, VALUE *argv, VALUE self)
345
461
  {
346
462
  ID ivar_window = rb_intern(kRB_IVAR_WINDOW_INTERNAL);
@@ -413,8 +529,11 @@ static VALUE rb_window_new(int argc, VALUE *argv, VALUE self)
413
529
 
414
530
 
415
531
 
416
- /* GLFWAPI void glfwDestroyWindow(GLFWwindow* window); */
417
-
532
+ /*
533
+ * Destroys the window.
534
+ *
535
+ * Wraps glfwDestroyWindow.
536
+ */
418
537
  static VALUE rb_window_destroy(VALUE self)
419
538
  {
420
539
  GLFWwindow *window = rb_get_window(self);
@@ -429,8 +548,14 @@ static VALUE rb_window_destroy(VALUE self)
429
548
 
430
549
 
431
550
 
432
- /* GLFWAPI int glfwWindowShouldClose(GLFWwindow* window); */
433
-
551
+ /*
552
+ * Gets the window's should-close flag.
553
+ *
554
+ * call-seq:
555
+ * should_close? -> true or false
556
+ *
557
+ * Wraps glfwWindowShouldClose.
558
+ */
434
559
  static VALUE rb_window_should_close(VALUE self)
435
560
  {
436
561
  GLFWwindow *window = rb_get_window(self);
@@ -439,29 +564,51 @@ static VALUE rb_window_should_close(VALUE self)
439
564
 
440
565
 
441
566
 
442
- /* GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value); */
443
-
567
+ /*
568
+ * Sets the window's should-close flag. Ideally, the value provided should be
569
+ * a boolean, though it is only tested for non-nil and -false status, so it can
570
+ * be anything that would yield true for !!value.
571
+ *
572
+ * call-seq:
573
+ * should_close=(value) -> value
574
+ * should_close = value -> value
575
+ *
576
+ * Wraps glfwSetWindowShouldClose.
577
+ */
444
578
  static VALUE rb_window_set_should_close(VALUE self, VALUE value)
445
579
  {
446
580
  GLFWwindow *window = rb_get_window(self);
447
581
  glfwSetWindowShouldClose(window, RTEST(value) ? GL_TRUE : GL_FALSE);
448
- return self;
582
+ return value;
449
583
  }
450
584
 
451
585
 
452
586
 
453
- /* GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title); */
454
-
455
- static VALUE rb_window_set_title(VALUE self, VALUE title)
587
+ /*
588
+ * Sets the window's title.
589
+ *
590
+ * call-seq:
591
+ * title=(new_title) -> new_title
592
+ * title = new_title -> new_title
593
+ *
594
+ * Wraps glfwSetWindowTitle.
595
+ */
596
+ static VALUE rb_window_set_title(VALUE self, VALUE new_title)
456
597
  {
457
- glfwSetWindowTitle(rb_get_window(self), StringValueCStr(title));
458
- return title;
598
+ glfwSetWindowTitle(rb_get_window(self), StringValueCStr(new_title));
599
+ return new_title;
459
600
  }
460
601
 
461
602
 
462
603
 
463
- /* GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos); */
464
-
604
+ /*
605
+ * Gets the windows position.
606
+ *
607
+ * call-seq:
608
+ * position -> [x, y]
609
+ *
610
+ * Wraps glfwGetWindowPos.
611
+ */
465
612
  static VALUE rb_window_get_position(VALUE self)
466
613
  {
467
614
  int xpos = 0;
@@ -472,8 +619,15 @@ static VALUE rb_window_get_position(VALUE self)
472
619
 
473
620
 
474
621
 
475
- /* GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos); */
476
-
622
+ /*
623
+ * Moves the window to a new location (sets its position).
624
+ *
625
+ * call-seq:
626
+ * set_position(x, y) -> self
627
+ * move(x, y) -> self
628
+ *
629
+ * Wraps glfwSetWindowPos.
630
+ */
477
631
  static VALUE rb_window_set_position(VALUE self, VALUE x, VALUE y)
478
632
  {
479
633
  glfwSetWindowPos(rb_get_window(self), NUM2INT(x), NUM2INT(y));
@@ -482,8 +636,14 @@ static VALUE rb_window_set_position(VALUE self, VALUE x, VALUE y)
482
636
 
483
637
 
484
638
 
485
- /* GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height); */
486
-
639
+ /*
640
+ * Gets the window's size.
641
+ *
642
+ * call-seq:
643
+ * size -> [width, height]
644
+ *
645
+ * Wraps glfwGetWindowSize.
646
+ */
487
647
  static VALUE rb_window_get_size(VALUE self)
488
648
  {
489
649
  int width = 0;
@@ -494,8 +654,15 @@ static VALUE rb_window_get_size(VALUE self)
494
654
 
495
655
 
496
656
 
497
- /* GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height); */
498
-
657
+ /*
658
+ * Sets the window's size.
659
+ *
660
+ * call-seq:
661
+ * set_size(width, height) -> self
662
+ * resize(width, height) -> self
663
+ *
664
+ * Wraps glfwSetWindowSize.
665
+ */
499
666
  static VALUE rb_window_set_size(VALUE self, VALUE width, VALUE height)
500
667
  {
501
668
  glfwSetWindowSize(rb_get_window(self), NUM2INT(width), NUM2INT(height));
@@ -504,8 +671,14 @@ static VALUE rb_window_set_size(VALUE self, VALUE width, VALUE height)
504
671
 
505
672
 
506
673
 
507
- /* GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height); */
508
-
674
+ /*
675
+ * Gets the window context's framebuffer size.
676
+ *
677
+ * call-seq:
678
+ * framebuffer_size -> [width, height]
679
+ *
680
+ * Wraps glfwGetFramebufferSize.
681
+ */
509
682
  static VALUE rb_window_get_framebuffer_size(VALUE self)
510
683
  {
511
684
  int width = 0;
@@ -516,8 +689,11 @@ static VALUE rb_window_get_framebuffer_size(VALUE self)
516
689
 
517
690
 
518
691
 
519
- /* GLFWAPI void glfwIconifyWindow(GLFWwindow* window); */
520
-
692
+ /*
693
+ * Iconifies the window.
694
+ *
695
+ * Wraps glfwIconifyWindow.
696
+ */
521
697
  static VALUE rb_window_iconify(VALUE self)
522
698
  {
523
699
  glfwIconifyWindow(rb_get_window(self));
@@ -526,8 +702,11 @@ static VALUE rb_window_iconify(VALUE self)
526
702
 
527
703
 
528
704
 
529
- /* GLFWAPI void glfwRestoreWindow(GLFWwindow* window); */
530
-
705
+ /*
706
+ * Restores the window.
707
+ *
708
+ * Wraps glfwRestoreWindow.
709
+ */
531
710
  static VALUE rb_window_restore(VALUE self)
532
711
  {
533
712
  glfwRestoreWindow(rb_get_window(self));
@@ -536,8 +715,11 @@ static VALUE rb_window_restore(VALUE self)
536
715
 
537
716
 
538
717
 
539
- /* GLFWAPI void glfwShowWindow(GLFWwindow* window); */
540
-
718
+ /*
719
+ * Shows the window.
720
+ *
721
+ * Wraps glfwShowWindow.
722
+ */
541
723
  static VALUE rb_window_show(VALUE self)
542
724
  {
543
725
  glfwShowWindow(rb_get_window(self));
@@ -546,8 +728,11 @@ static VALUE rb_window_show(VALUE self)
546
728
 
547
729
 
548
730
 
549
- /* GLFWAPI void glfwHideWindow(GLFWwindow* window); */
550
-
731
+ /*
732
+ * Hides the window.
733
+ *
734
+ * Wraps glfwHideWindow.
735
+ */
551
736
  static VALUE rb_window_hide(VALUE self)
552
737
  {
553
738
  glfwHideWindow(rb_get_window(self));
@@ -556,8 +741,14 @@ static VALUE rb_window_hide(VALUE self)
556
741
 
557
742
 
558
743
 
559
- /* GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window); */
560
-
744
+ /*
745
+ * Gets the window's monitor.
746
+ *
747
+ * call-seq:
748
+ * monitor -> Glfw::Monitor
749
+ *
750
+ * Wraps glfwGetWindowMonitor.
751
+ */
561
752
  static VALUE rb_window_get_monitor(VALUE self)
562
753
  {
563
754
  GLFWmonitor *monitor = glfwGetWindowMonitor(rb_get_window(self));
@@ -568,14 +759,6 @@ static VALUE rb_window_get_monitor(VALUE self)
568
759
 
569
760
 
570
761
 
571
- /* GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib); */
572
-
573
-
574
-
575
-
576
-
577
- /* GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun cbfun); */
578
-
579
762
  static void rb_window_window_position_callback(GLFWwindow *window, int x, int y)
580
763
  {
581
764
  VALUE rb_window = rb_lookup_window(window);
@@ -587,9 +770,6 @@ RB_ENABLE_CALLBACK_DEF(rb_window_set_window_position_callback, rb_window_window_
587
770
 
588
771
 
589
772
 
590
-
591
- /* GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun cbfun); */
592
-
593
773
  static void rb_window_window_size_callback(GLFWwindow *window, int width, int height)
594
774
  {
595
775
  VALUE rb_window = rb_lookup_window(window);
@@ -601,8 +781,6 @@ RB_ENABLE_CALLBACK_DEF(rb_window_set_window_size_callback, rb_window_window_size
601
781
 
602
782
 
603
783
 
604
- /* GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun cbfun); */
605
-
606
784
  static void rb_window_close_callback(GLFWwindow *window)
607
785
  {
608
786
  VALUE rb_window = rb_lookup_window(window);
@@ -614,9 +792,6 @@ RB_ENABLE_CALLBACK_DEF(rb_window_set_close_callback, rb_window_close_callback, g
614
792
 
615
793
 
616
794
 
617
-
618
- /* GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun cbfun); */
619
-
620
795
  static void rb_window_refresh_callback(GLFWwindow *window)
621
796
  {
622
797
  VALUE rb_window = rb_lookup_window(window);
@@ -628,8 +803,6 @@ RB_ENABLE_CALLBACK_DEF(rb_window_set_refresh_callback, rb_window_refresh_callbac
628
803
 
629
804
 
630
805
 
631
- /* GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun cbfun); */
632
-
633
806
  static void rb_window_focus_callback(GLFWwindow *window, int focused)
634
807
  {
635
808
  VALUE rb_window = rb_lookup_window(window);
@@ -641,8 +814,6 @@ RB_ENABLE_CALLBACK_DEF(rb_window_set_focus_callback, rb_window_focus_callback, g
641
814
 
642
815
 
643
816
 
644
- /* GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun cbfun); */
645
-
646
817
  static void rb_window_iconify_callback(GLFWwindow *window, int iconified)
647
818
  {
648
819
  VALUE rb_window = rb_lookup_window(window);
@@ -654,9 +825,6 @@ RB_ENABLE_CALLBACK_DEF(rb_window_set_iconify_callback, rb_window_iconify_callbac
654
825
 
655
826
 
656
827
 
657
- /* GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun) */
658
-
659
-
660
828
  static void rb_window_fbsize_callback(GLFWwindow *window, int width, int height)
661
829
  {
662
830
  VALUE rb_window = rb_lookup_window(window);
@@ -668,8 +836,19 @@ RB_ENABLE_CALLBACK_DEF(rb_window_set_fbsize_callback, rb_window_fbsize_callback,
668
836
 
669
837
 
670
838
 
671
- /* GLFWAPI void glfwPollEvents(void); */
672
-
839
+ /*
840
+ * Polls for events without blocking until an event occurs.
841
+ *
842
+ * Wraps glfwPollEvents.
843
+ *
844
+ * This would likely be called at the beginning of your main loop, like so:
845
+ *
846
+ * loop {
847
+ * Glfw.poll_events()
848
+ *
849
+ * # ...
850
+ * }
851
+ */
673
852
  static VALUE rb_glfw_poll_events(VALUE self)
674
853
  {
675
854
  glfwPollEvents();
@@ -678,8 +857,19 @@ static VALUE rb_glfw_poll_events(VALUE self)
678
857
 
679
858
 
680
859
 
681
- /* GLFWAPI void glfwWaitEvents(void); */
682
-
860
+ /*
861
+ * Polls for events. Blocks until an event occurs.
862
+ *
863
+ * Wraps glfwWaitEvents.
864
+ *
865
+ * This would likely be called at the beginning of your main loop, like so:
866
+ *
867
+ * loop {
868
+ * Glfw.wait_events()
869
+ *
870
+ * # ...
871
+ * }
872
+ */
683
873
  static VALUE rb_glfw_wait_events(VALUE self)
684
874
  {
685
875
  glfwWaitEvents();
@@ -688,8 +878,14 @@ static VALUE rb_glfw_wait_events(VALUE self)
688
878
 
689
879
 
690
880
 
691
- /* GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode); */
692
-
881
+ /*
882
+ * Gets the current value for the given input mode.
883
+ *
884
+ * call-seq:
885
+ * get_input_mode(mode) -> Fixed
886
+ *
887
+ * Wraps glfwGetInputMode.
888
+ */
693
889
  static VALUE rb_window_get_input_mode(VALUE self, VALUE mode)
694
890
  {
695
891
  return INT2FIX(glfwGetInputMode(rb_get_window(self), NUM2INT(mode)));
@@ -697,8 +893,14 @@ static VALUE rb_window_get_input_mode(VALUE self, VALUE mode)
697
893
 
698
894
 
699
895
 
700
- /* GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value); */
701
-
896
+ /*
897
+ * Sets the value of the given input mode.
898
+ *
899
+ * call-seq:
900
+ * set_input_mode(mode, value) -> self
901
+ *
902
+ * Wraps glfwSetInputMode.
903
+ */
702
904
  static VALUE rb_window_set_input_mode(VALUE self, VALUE mode, VALUE value)
703
905
  {
704
906
  glfwSetInputMode(rb_get_window(self), NUM2INT(mode), NUM2INT(value));
@@ -707,8 +909,14 @@ static VALUE rb_window_set_input_mode(VALUE self, VALUE mode, VALUE value)
707
909
 
708
910
 
709
911
 
710
- /* GLFWAPI int glfwGetKey(GLFWwindow* window, int key); */
711
-
912
+ /*
913
+ * Gets the last-reported state of the given keyboard key for the window.
914
+ *
915
+ * call-seq:
916
+ * key(key) -> Fixed
917
+ *
918
+ * Wraps glfwGetKey.
919
+ */
712
920
  static VALUE rb_window_get_key(VALUE self, VALUE key)
713
921
  {
714
922
  return INT2FIX(glfwGetKey(rb_get_window(self), NUM2INT(key)));
@@ -716,8 +924,14 @@ static VALUE rb_window_get_key(VALUE self, VALUE key)
716
924
 
717
925
 
718
926
 
719
- /* GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button); */
720
-
927
+ /*
928
+ * Gets the last-reported state of the given mouse button for the window.
929
+ *
930
+ * call-seq:
931
+ * mouse_button(key) -> Fixed
932
+ *
933
+ * Wraps glfwGetMouseButton.
934
+ */
721
935
  static VALUE rb_window_get_mouse_button(VALUE self, VALUE button)
722
936
  {
723
937
  return INT2FIX(glfwGetMouseButton(rb_get_window(self), NUM2INT(button)));
@@ -725,8 +939,14 @@ static VALUE rb_window_get_mouse_button(VALUE self, VALUE button)
725
939
 
726
940
 
727
941
 
728
- /* GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos); */
729
-
942
+ /*
943
+ * Gets the last-reported cursor position in the window.
944
+ *
945
+ * call-seq:
946
+ * cursor_pos -> [x, y]
947
+ *
948
+ * Wraps glfwGetCursorPos.
949
+ */
730
950
  static VALUE rb_window_get_cursor_pos(VALUE self)
731
951
  {
732
952
  double xpos = 0;
@@ -737,8 +957,16 @@ static VALUE rb_window_get_cursor_pos(VALUE self)
737
957
 
738
958
 
739
959
 
740
- /* GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos); */
741
-
960
+ /*
961
+ * Sets the position of the mouse cursor relative to the client area of the
962
+ * window. If the window isn't focused at the time of the call, this silently
963
+ * fails.
964
+ *
965
+ * call-seq:
966
+ * set_cursor_pos(x, y) -> self
967
+ *
968
+ * Wraps glfwSetCursorPos.
969
+ */
742
970
  static VALUE rb_window_set_cursor_pos(VALUE self, VALUE x, VALUE y)
743
971
  {
744
972
  glfwSetCursorPos(rb_get_window(self), NUM2DBL(x), NUM2DBL(y));
@@ -747,8 +975,6 @@ static VALUE rb_window_set_cursor_pos(VALUE self, VALUE x, VALUE y)
747
975
 
748
976
 
749
977
 
750
- /* GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun); */
751
-
752
978
  static void rb_window_key_callback(GLFWwindow *window, int key, int scancode, int action, int mods)
753
979
  {
754
980
  VALUE rb_window = rb_lookup_window(window);
@@ -760,8 +986,6 @@ RB_ENABLE_CALLBACK_DEF(rb_window_set_key_callback, rb_window_key_callback, glfwS
760
986
 
761
987
 
762
988
 
763
- /* GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun); */
764
-
765
989
  static void rb_window_char_callback(GLFWwindow *window, unsigned int code)
766
990
  {
767
991
  VALUE rb_window = rb_lookup_window(window);
@@ -774,8 +998,6 @@ RB_ENABLE_CALLBACK_DEF(rb_window_set_char_callback, rb_window_char_callback, glf
774
998
 
775
999
 
776
1000
 
777
- /* GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun); */
778
-
779
1001
  static void rb_window_mouse_button_callback(GLFWwindow *window, int button, int action, int mods)
780
1002
  {
781
1003
  VALUE rb_window = rb_lookup_window(window);
@@ -787,8 +1009,6 @@ RB_ENABLE_CALLBACK_DEF(rb_window_set_mouse_button_callback, rb_window_mouse_butt
787
1009
 
788
1010
 
789
1011
 
790
- /* GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun cbfun); */
791
-
792
1012
  static void rb_window_cursor_position_callback(GLFWwindow *window, double x, double y)
793
1013
  {
794
1014
  VALUE rb_window = rb_lookup_window(window);
@@ -800,8 +1020,6 @@ RB_ENABLE_CALLBACK_DEF(rb_window_set_cursor_position_callback, rb_window_cursor_
800
1020
 
801
1021
 
802
1022
 
803
- /* GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun cbfun); */
804
-
805
1023
  static void rb_window_cursor_enter_callback(GLFWwindow *window, int entered)
806
1024
  {
807
1025
  VALUE rb_window = rb_lookup_window(window);
@@ -813,8 +1031,6 @@ RB_ENABLE_CALLBACK_DEF(rb_window_set_cursor_enter_callback, rb_window_cursor_ent
813
1031
 
814
1032
 
815
1033
 
816
- /* GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cbfun); */
817
-
818
1034
  static void rb_window_scroll_callback(GLFWwindow *window, double x, double y)
819
1035
  {
820
1036
  VALUE rb_window = rb_lookup_window(window);
@@ -827,17 +1043,30 @@ RB_ENABLE_CALLBACK_DEF(rb_window_set_scroll_callback, rb_window_scroll_callback,
827
1043
 
828
1044
 
829
1045
 
830
- /* GLFWAPI int glfwJoystickPresent(int joy); */
831
-
832
- static VALUE rb_glfw_joysitck_present(VALUE self, VALUE joystick)
1046
+ /*
1047
+ * Returns whether the given joystick is present.
1048
+ *
1049
+ * call-seq:
1050
+ * joystick_present?(joystick) -> true or false
1051
+ *
1052
+ * Wraps glfwJoystickPresent.
1053
+ */
1054
+ static VALUE rb_glfw_joystick_present(VALUE self, VALUE joystick)
833
1055
  {
834
1056
  return glfwJoystickPresent(NUM2INT(joystick)) ? Qtrue : Qfalse;
835
1057
  }
836
1058
 
837
1059
 
838
1060
 
839
- /* GLFWAPI const float* glfwGetJoystickAxes(int joy, int* count); */
840
-
1061
+ /*
1062
+ * Gets the values of all axes of the given joystick. Returns nil if the
1063
+ * joystick isn't present. See #joystick_present?.
1064
+ *
1065
+ * call-seq:
1066
+ * joystick_axes(joystick) -> [Float, ...] or nil
1067
+ *
1068
+ * Wraps glfwGetJoystickAxes.
1069
+ */
841
1070
  static VALUE rb_glfw_get_joystick_axes(VALUE self, VALUE joystick)
842
1071
  {
843
1072
  VALUE rb_axes = Qnil;
@@ -854,8 +1083,15 @@ static VALUE rb_glfw_get_joystick_axes(VALUE self, VALUE joystick)
854
1083
 
855
1084
 
856
1085
 
857
- /* GLFWAPI const unsigned char* glfwGetJoystickButtons(int joy, int* count); */
858
-
1086
+ /*
1087
+ * Gets the button values of the given joystick. Returns nil if the joystick
1088
+ * isn't present. See #joystick_present?.
1089
+ *
1090
+ * call-seq:
1091
+ * joystick_buttons(joystick) -> [Fixed, ...] or nil
1092
+ *
1093
+ * Wraps glfwGetJoystickButtons.
1094
+ */
859
1095
  static VALUE rb_glfw_get_joystick_buttons(VALUE self, VALUE joystick)
860
1096
  {
861
1097
  VALUE rb_buttons = Qnil;
@@ -872,8 +1108,14 @@ static VALUE rb_glfw_get_joystick_buttons(VALUE self, VALUE joystick)
872
1108
 
873
1109
 
874
1110
 
875
- /* GLFWAPI const char* glfwGetJoystickName(int joy); */
876
-
1111
+ /*
1112
+ * Returns the name of the given joystick.
1113
+ *
1114
+ * call-seq:
1115
+ * joystick_name(joystick) -> String
1116
+ *
1117
+ * Wraps glfwGetJoystickName.
1118
+ */
877
1119
  static VALUE rb_glfw_get_joystick_name(VALUE self, VALUE joystick)
878
1120
  {
879
1121
  const char *joy_name = glfwGetJoystickName(NUM2INT(joystick));
@@ -886,8 +1128,16 @@ static VALUE rb_glfw_get_joystick_name(VALUE self, VALUE joystick)
886
1128
 
887
1129
 
888
1130
 
889
- /* GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string); */
890
-
1131
+ /*
1132
+ * Sets the system clipboard string. The window this is set for will own the
1133
+ * given string.
1134
+ *
1135
+ * call-seq:
1136
+ * clipboard_string=(string) -> String
1137
+ * clipboard_string = string -> String
1138
+ *
1139
+ * Wraps glfwSetClipboardString.
1140
+ */
891
1141
  static VALUE rb_window_set_clipboard_string(VALUE self, VALUE string)
892
1142
  {
893
1143
  glfwSetClipboardString(rb_get_window(self), StringValueCStr(string));
@@ -896,8 +1146,15 @@ static VALUE rb_window_set_clipboard_string(VALUE self, VALUE string)
896
1146
 
897
1147
 
898
1148
 
899
- /* GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window); */
900
-
1149
+ /*
1150
+ * Gets the system clipboard's contents as a string. The window this is called
1151
+ * from will request the clipboard contents.
1152
+ *
1153
+ * call-seq:
1154
+ * clipboard_string() -> String
1155
+ *
1156
+ * Wraps glfwGetClipboardString.
1157
+ */
901
1158
  static VALUE rb_window_get_clipboard_string(VALUE self)
902
1159
  {
903
1160
  return rb_str_new2(glfwGetClipboardString(rb_get_window(self)));
@@ -905,8 +1162,15 @@ static VALUE rb_window_get_clipboard_string(VALUE self)
905
1162
 
906
1163
 
907
1164
 
908
- /* GLFWAPI double glfwGetTime(void); */
909
-
1165
+ /*
1166
+ * Gets the current time in seconds. The returned time is relative to the time
1167
+ * since GLFW was initialized unless the time has been set using #timer=.
1168
+ *
1169
+ * call-seq:
1170
+ * time -> Float
1171
+ *
1172
+ * Wraps glfwGetTime.
1173
+ */
910
1174
  static VALUE rb_glfw_get_time(VALUE self)
911
1175
  {
912
1176
  return rb_float_new(glfwGetTime());
@@ -914,8 +1178,17 @@ static VALUE rb_glfw_get_time(VALUE self)
914
1178
 
915
1179
 
916
1180
 
917
- /* GLFWAPI void glfwSetTime(double time); */
918
-
1181
+ /*
1182
+ * Sets the current time in seconds. If set, GLFW will continue measuring time
1183
+ * elapsed from that time forward.
1184
+ *
1185
+ * In most cases, you will not need to use this.
1186
+ *
1187
+ * call-seq:
1188
+ * time = Float
1189
+ *
1190
+ * Wraps glfwSetTime.
1191
+ */
919
1192
  static VALUE rb_glfw_set_time(VALUE self, VALUE time_)
920
1193
  {
921
1194
  glfwSetTime(NUM2DBL(time_));
@@ -924,8 +1197,23 @@ static VALUE rb_glfw_set_time(VALUE self, VALUE time_)
924
1197
 
925
1198
 
926
1199
 
927
- /* GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window); */
928
-
1200
+ /*
1201
+ * Makes the window's GL context current. You will need to call this before
1202
+ * calling any OpenGL functions. See also ::unset_context to unset a context.
1203
+ *
1204
+ * Wraps glfwMakeContextCurrent(window).
1205
+ *
1206
+ * # Good
1207
+ * window.make_context_current()
1208
+ * Gl.glClear(Gl::GL_COLOR_BUFFER_BIT)
1209
+ *
1210
+ * # Bad
1211
+ * Gl.glClear(Gl::GL_COLOR_BUFFER_BIT)
1212
+ * window.make_context_current()
1213
+ *
1214
+ * Remember to make a window's context current before calling any OpenGL
1215
+ * functions. A window's GL context may only be current in one thread at a time.
1216
+ */
929
1217
  static VALUE rb_window_make_context_current(VALUE self)
930
1218
  {
931
1219
  glfwMakeContextCurrent(rb_get_window(self));
@@ -934,8 +1222,27 @@ static VALUE rb_window_make_context_current(VALUE self)
934
1222
 
935
1223
 
936
1224
 
937
- /* GLFWAPI GLFWwindow* glfwGetCurrentContext(void); */
1225
+ /*
1226
+ * Unsets the current GL context.
1227
+ *
1228
+ * Wraps glfwMakeContextCurrent(NULL).
1229
+ */
1230
+ static VALUE rb_window_unset_context(VALUE self)
1231
+ {
1232
+ glfwMakeContextCurrent(NULL);
1233
+ return self;
1234
+ }
1235
+
938
1236
 
1237
+
1238
+ /*
1239
+ * Gets the window for the current GL context in this thread.
1240
+ *
1241
+ * call-seq:
1242
+ * current_context() -> Glfw::Window
1243
+ *
1244
+ * Wraps glfwGetCurrentContext.
1245
+ */
939
1246
  static VALUE rb_window_get_current_context(VALUE self)
940
1247
  {
941
1248
  GLFWwindow *window = glfwGetCurrentContext();
@@ -948,8 +1255,20 @@ static VALUE rb_window_get_current_context(VALUE self)
948
1255
 
949
1256
 
950
1257
 
951
- /* GLFWAPI void glfwSwapBuffers(GLFWwindow* window); */
952
-
1258
+ /*
1259
+ * Swaps the front and back buffers for the window. You will typically call this
1260
+ * at the end of your drawing routines.
1261
+ *
1262
+ * Wraps glfwSwapBuffers.
1263
+ *
1264
+ * loop {
1265
+ * Glfw.poll_events()
1266
+ *
1267
+ * # ...
1268
+ *
1269
+ * window.swap_buffers()
1270
+ * }
1271
+ */
953
1272
  static VALUE rb_window_swap_buffers(VALUE self)
954
1273
  {
955
1274
  glfwSwapBuffers(rb_get_window(self));
@@ -958,20 +1277,41 @@ static VALUE rb_window_swap_buffers(VALUE self)
958
1277
 
959
1278
 
960
1279
 
961
- /* GLFWAPI void glfwSwapInterval(int interval); */
962
-
963
- static VALUE rb_glfw_swap_interval(VALUE self)
1280
+ /*
1281
+ * Sets the swap interval for the current context.
1282
+ * (See Glfw::Window#make_context_current)
1283
+ *
1284
+ * call-seq:
1285
+ * swap_interval=(interval) -> self
1286
+ * swap_interval = interval -> self
1287
+ *
1288
+ * Wraps glfwSwapInterval.
1289
+ */
1290
+ static VALUE rb_glfw_swap_interval(VALUE self, VALUE interval)
964
1291
  {
1292
+ glfwSwapInterval(NUM2INT(interval));
965
1293
  return self;
966
1294
  }
967
1295
 
968
1296
 
969
1297
 
970
- /* GLFWAPI int glfwExtensionSupported(const char* extension); */
971
-
972
- static VALUE rb_glfw_extension_supported(VALUE self)
1298
+ /*
1299
+ * Retursn whether a given OpenGL or context creation API extension is supported
1300
+ * by the current context.
1301
+ * (See Glfw::Window#make_context_current)
1302
+ *
1303
+ * Bear in mind that this function does not cache its results, so calls may be
1304
+ * expensive. If you find yourself using it, consider caching the results
1305
+ * yourself.
1306
+ *
1307
+ * call-seq:
1308
+ * extension_supported?(extension) -> true or false
1309
+ *
1310
+ * Wraps glfwExtensionSupported.
1311
+ */
1312
+ static VALUE rb_glfw_extension_supported(VALUE self, VALUE extension)
973
1313
  {
974
- return self;
1314
+ return glfwExtensionSupported(StringValueCStr(extension)) ? Qtrue : Qfalse;
975
1315
  }
976
1316
 
977
1317
 
@@ -985,6 +1325,8 @@ void Init_glfw3(void)
985
1325
  s_glfw_videomode_klass = rb_define_class_under(s_glfw_module, "VideoMode", rb_cObject);
986
1326
 
987
1327
  /* Glfw::Monitor */
1328
+ rb_define_singleton_method(s_glfw_monitor_klass, "monitors", rb_glfw_get_monitors, 0);
1329
+ rb_define_singleton_method(s_glfw_monitor_klass, "primary_monitor", rb_glfw_get_primary_monitor, 0);
988
1330
  rb_define_method(s_glfw_monitor_klass, "name", rb_monitor_name, 0);
989
1331
  rb_define_method(s_glfw_monitor_klass, "position", rb_monitor_position, 0);
990
1332
  rb_define_method(s_glfw_monitor_klass, "physical_size", rb_monitor_physical_size, 0);
@@ -1004,6 +1346,7 @@ void Init_glfw3(void)
1004
1346
  rb_define_singleton_method(s_glfw_window_klass, "new", rb_window_new, -1);
1005
1347
  rb_define_singleton_method(s_glfw_window_klass, "window_hint", rb_window_window_hint, 2);
1006
1348
  rb_define_singleton_method(s_glfw_window_klass, "default_window_hints", rb_window_default_window_hints, 0);
1349
+ rb_define_singleton_method(s_glfw_window_klass, "unset_context", rb_window_unset_context, 0);
1007
1350
  // rb_define_method(s_glfw_window_klass, "initialize", rb_window_init, -1);
1008
1351
  rb_define_method(s_glfw_window_klass, "destroy", rb_window_destroy, 0);
1009
1352
  rb_define_method(s_glfw_window_klass, "should_close?", rb_window_should_close, 0);
@@ -1014,8 +1357,10 @@ void Init_glfw3(void)
1014
1357
  rb_define_method(s_glfw_window_klass, "swap_buffers", rb_window_swap_buffers, 0);
1015
1358
  rb_define_method(s_glfw_window_klass, "title=", rb_window_set_title, 1);
1016
1359
  rb_define_method(s_glfw_window_klass, "position", rb_window_get_position, 0);
1360
+ rb_define_method(s_glfw_window_klass, "set_position", rb_window_set_position, 2);
1017
1361
  rb_define_method(s_glfw_window_klass, "move", rb_window_set_position, 2);
1018
1362
  rb_define_method(s_glfw_window_klass, "size", rb_window_get_size, 0);
1363
+ rb_define_method(s_glfw_window_klass, "set_size", rb_window_set_size, 2);
1019
1364
  rb_define_method(s_glfw_window_klass, "resize", rb_window_set_size, 2);
1020
1365
  rb_define_method(s_glfw_window_klass, "framebuffer_size", rb_window_get_framebuffer_size, 0);
1021
1366
  rb_define_method(s_glfw_window_klass, "iconify", rb_window_iconify, 0);
@@ -1052,11 +1397,9 @@ void Init_glfw3(void)
1052
1397
  rb_define_singleton_method(s_glfw_module, "version", rb_glfw_version, 0);
1053
1398
  rb_define_singleton_method(s_glfw_module, "terminate", rb_glfw_terminate, 0);
1054
1399
  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
1400
  rb_define_singleton_method(s_glfw_module, "poll_events", rb_glfw_poll_events, 0);
1058
1401
  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);
1402
+ rb_define_singleton_method(s_glfw_module, "joystick_present?", rb_glfw_joystick_present, 1);
1060
1403
  rb_define_singleton_method(s_glfw_module, "joystick_axes", rb_glfw_get_joystick_axes, 1);
1061
1404
  rb_define_singleton_method(s_glfw_module, "joystick_buttons", rb_glfw_get_joystick_buttons, 1);
1062
1405
  rb_define_singleton_method(s_glfw_module, "joystick_name", rb_glfw_get_joystick_name, 1);