opengl-bindings 1.5.2 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +6 -0
  3. data/README.md +3 -1
  4. data/lib/glfw.rb +93 -21
  5. data/lib/glfw30.rb +95 -1
  6. data/lib/glut.rb +103 -3
  7. metadata +6 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d4a60f9ec6d0edcd730c35b05c2f9df9c9dff38
4
- data.tar.gz: d8bfff5e139aef4e2b2bb0278a0824332db86b09
3
+ metadata.gz: 7d1181366105ac620b6d2bf3ac88f35b12e679b4
4
+ data.tar.gz: 6af43be448019a8dde0760bc21c0006236b62262
5
5
  SHA512:
6
- metadata.gz: e5398895ad2c8c2c126672f22b45fb549f3c988fbe916abcb6a031371955ada73cb3f393d7259309ad0bb10c07ae69b3515b7a11f7ee330008e0f3041072c181
7
- data.tar.gz: 7cbe82566492a6a5520173590cffaa320f5d512f9fea172c8b732e90b2aafa2ee0297f04b30898103b7949d4a32f5dc85bb653b1635f3f2911738016987faff6
6
+ metadata.gz: a53565b006f89a468591682d380180eae80943e73d833a2052fd32309c6849d3ee34f02b6a0f7680e4f2f1397ba53b480ff4c4b5f122cb30bdd748b6815eff60
7
+ data.tar.gz: e25ea1bb3898eb82b58aaa1c6a33a47e14af4cf25a33101191d282235ab659d2d1510c79ad38a4d98c63ae98dbc159e76c35fdd20ae43e8fe8869476c9bc3605
data/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ 2015-12-29 vaiorabbit <http://twitter.com/vaiorabbit>
2
+
3
+ * lib/glfw.rb, lib/glfw30.rb, lib/glut.rb: 'create_callback' now creates
4
+ callback functions as an instance of Fiddle::Closure::BlockCaller. Old
5
+ methods are still available (renamed to create_callback_function').
6
+
1
7
  2015-11-14 vaiorabbit <http://twitter.com/vaiorabbit>
2
8
 
3
9
  * lib/opengl_linux.rb (glXGetCurrentDisplay): Fixed wrong signature.
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  ...and wrapper code generator.
6
6
 
7
7
  * Created : 2013-08-28
8
- * Last modified : 2015-11-14
8
+ * Last modified : 2015-12-29
9
9
 
10
10
 
11
11
  ## Features ##
@@ -104,6 +104,7 @@ Use GLFW or GLUT for creating windows and OpenGL rendering contexts.
104
104
  ## Tested Environment ##
105
105
 
106
106
  * Ruby
107
+ * ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
107
108
  * ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
108
109
  * ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
109
110
  * ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
@@ -311,6 +312,7 @@ GLFW か GLUT を用意してください。ウィンドウやレンダリング
311
312
  ## テストした環境 ##
312
313
 
313
314
  * Ruby
315
+ * ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
314
316
  * ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
315
317
  * ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
316
318
  * ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
@@ -1,4 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
+ # A GLFW wrapper (for version 3.1)
2
3
  require 'fiddle/import'
3
4
 
4
5
  module GLFW
@@ -284,35 +285,106 @@ module GLFW
284
285
  GLFW_DONT_CARE = -1
285
286
 
286
287
  # typedefs
287
- @@glfw_cb_signature = {
288
- :GLFWglproc => "void GLFWglproc()",
289
- :GLFWerrorfun => "void GLFWerrorfun(int,const char*)",
290
- :GLFWwindowposfun => "void GLFWwindowposfun(void*,int,int)",
291
- :GLFWwindowsizefun => "void GLFWwindowsizefun(void*,int,int)",
292
- :GLFWwindowclosefun => "void GLFWwindowclosefun(void*)",
293
- :GLFWwindowrefreshfun => "void GLFWwindowrefreshfun(void*)",
294
- :GLFWwindowfocusfun => "void GLFWwindowfocusfun(void*,int)",
295
- :GLFWwindowiconifyfun => "void GLFWwindowiconifyfun(void*,int)",
288
+ @@glfw_cb_function_signature = {
289
+ :GLFWerrorfun => "void GLFWerrorfun(int,const char*)",
290
+ :GLFWwindowposfun => "void GLFWwindowposfun(void*,int,int)",
291
+ :GLFWwindowsizefun => "void GLFWwindowsizefun(void*,int,int)",
292
+ :GLFWwindowclosefun => "void GLFWwindowclosefun(void*)",
293
+ :GLFWwindowrefreshfun => "void GLFWwindowrefreshfun(void*)",
294
+ :GLFWwindowfocusfun => "void GLFWwindowfocusfun(void*,int)",
295
+ :GLFWwindowiconifyfun => "void GLFWwindowiconifyfun(void*,int)",
296
296
  :GLFWframebuffersizefun => "void GLFWframebuffersizefun(void*,int,int)",
297
- :GLFWmousebuttonfun => "void GLFWmousebuttonfun(void*,int,int,int)",
298
- :GLFWcursorposfun => "void GLFWcursorposfun(void*,double,double)",
299
- :GLFWcursorenterfun => "void GLFWcursorenterfun(void*,int)",
300
- :GLFWscrollfun => "void GLFWscrollfun(void*,double,double)",
301
- :GLFWkeyfun => "void GLFWkeyfun(void*,int,int,int,int)",
302
- :GLFWcharfun => "void GLFWcharfun(void*,unsigned int)",
303
- :GLFWcharmodsfun => "void GLFWcharmodsfun(void*,unsigned int,int)",
304
- :GLFWdropfun => "void GLFWdropfun(void*,int,const char**)",
305
- :GLFWmonitorfun => "void GLFWmonitorfun(void*,int)",
297
+ :GLFWmousebuttonfun => "void GLFWmousebuttonfun(void*,int,int,int)",
298
+ :GLFWcursorposfun => "void GLFWcursorposfun(void*,double,double)",
299
+ :GLFWcursorenterfun => "void GLFWcursorenterfun(void*,int)",
300
+ :GLFWscrollfun => "void GLFWscrollfun(void*,double,double)",
301
+ :GLFWkeyfun => "void GLFWkeyfun(void*,int,int,int,int)",
302
+ :GLFWcharfun => "void GLFWcharfun(void*,unsigned int)",
303
+ :GLFWcharmodsfun => "void GLFWcharmodsfun(void*,unsigned int,int)",
304
+ :GLFWdropfun => "void GLFWdropfun(void*,int,const char**)",
305
+ :GLFWmonitorfun => "void GLFWmonitorfun(void*,int)",
306
306
  }
307
307
 
308
- def self.create_callback( sym, proc=nil, &blk )
308
+ # Creates a callback as an instance of Fiddle::Function
309
+ def self.create_callback_function( sym, proc=nil, &blk )
309
310
  if block_given?
310
- return bind( @@glfw_cb_signature[sym], nil, &blk )
311
+ return bind( @@glfw_cb_function_signature[sym], nil, &blk )
311
312
  else
312
- return bind( @@glfw_cb_signature[sym], nil, &proc )
313
+ return bind( @@glfw_cb_function_signature[sym], nil, &proc )
313
314
  end
314
315
  end
315
316
 
317
+ GLFWerrorfun_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_VOIDP]
318
+ GLFWerrorfun_cb_retval = Fiddle::TYPE_VOID
319
+ GLFWwindowposfun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
320
+ GLFWwindowposfun_cb_retval = Fiddle::TYPE_VOID
321
+ GLFWwindowsizefun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
322
+ GLFWwindowsizefun_cb_retval = Fiddle::TYPE_VOID
323
+ GLFWwindowclosefun_cb_args = [Fiddle::TYPE_VOIDP]
324
+ GLFWwindowclosefun_cb_retval = Fiddle::TYPE_VOID
325
+ GLFWwindowrefreshfun_cb_args = [Fiddle::TYPE_VOIDP]
326
+ GLFWwindowrefreshfun_cb_retval = Fiddle::TYPE_VOID
327
+ GLFWwindowfocusfun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT]
328
+ GLFWwindowfocusfun_cb_retval = Fiddle::TYPE_VOID
329
+ GLFWwindowiconifyfun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT]
330
+ GLFWwindowiconifyfun_cb_retval = Fiddle::TYPE_VOID
331
+ GLFWframebuffersizefun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
332
+ GLFWframebuffersizefun_cb_retval = Fiddle::TYPE_VOID
333
+ GLFWmousebuttonfun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
334
+ GLFWmousebuttonfun_cb_retval = Fiddle::TYPE_VOID
335
+ GLFWcursorposfun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_DOUBLE, Fiddle::TYPE_DOUBLE]
336
+ GLFWcursorposfun_cb_retval = Fiddle::TYPE_VOID
337
+ GLFWcursorenterfun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT]
338
+ GLFWcursorenterfun_cb_retval = Fiddle::TYPE_VOID
339
+ GLFWscrollfun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_DOUBLE, Fiddle::TYPE_DOUBLE]
340
+ GLFWscrollfun_cb_retval = Fiddle::TYPE_VOID
341
+ GLFWkeyfun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
342
+ GLFWkeyfun_cb_retval = Fiddle::TYPE_VOID
343
+ GLFWcharfun_cb_args = [Fiddle::TYPE_VOIDP, -Fiddle::TYPE_INT]
344
+ GLFWcharfun_cb_retval = Fiddle::TYPE_VOID
345
+ GLFWcharmodsfun_cb_args = [Fiddle::TYPE_VOIDP, -Fiddle::TYPE_INT, Fiddle::TYPE_INT]
346
+ GLFWcharmodsfun_cb_retval = Fiddle::TYPE_VOID
347
+ GLFWdropfun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT, Fiddle::TYPE_VOIDP]
348
+ GLFWdropfun_cb_retval = Fiddle::TYPE_VOID
349
+ GLFWmonitorfun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT]
350
+ GLFWmonitorfun_cb_retval = Fiddle::TYPE_VOID
351
+
352
+ @@glfw_cb_closure_signature = {
353
+ :GLFWerrorfun => [GLFWerrorfun_cb_retval, GLFWerrorfun_cb_args],
354
+ :GLFWwindowposfun => [GLFWwindowposfun_cb_retval, GLFWwindowposfun_cb_args],
355
+ :GLFWwindowsizefun => [GLFWwindowsizefun_cb_retval, GLFWwindowsizefun_cb_args],
356
+ :GLFWwindowclosefun => [GLFWwindowclosefun_cb_retval, GLFWwindowclosefun_cb_args],
357
+ :GLFWwindowrefreshfun => [GLFWwindowrefreshfun_cb_retval, GLFWwindowrefreshfun_cb_args],
358
+ :GLFWwindowfocusfun => [GLFWwindowfocusfun_cb_retval, GLFWwindowfocusfun_cb_args],
359
+ :GLFWwindowiconifyfun => [GLFWwindowiconifyfun_cb_retval, GLFWwindowiconifyfun_cb_args],
360
+ :GLFWframebuffersizefun => [GLFWframebuffersizefun_cb_retval, GLFWframebuffersizefun_cb_args],
361
+ :GLFWmousebuttonfun => [GLFWmousebuttonfun_cb_retval, GLFWmousebuttonfun_cb_args],
362
+ :GLFWcursorposfun => [GLFWcursorposfun_cb_retval, GLFWcursorposfun_cb_args],
363
+ :GLFWcursorenterfun => [GLFWcursorenterfun_cb_retval, GLFWcursorenterfun_cb_args],
364
+ :GLFWscrollfun => [GLFWscrollfun_cb_retval, GLFWscrollfun_cb_args],
365
+ :GLFWkeyfun => [GLFWkeyfun_cb_retval, GLFWkeyfun_cb_args],
366
+ :GLFWcharfun => [GLFWcharfun_cb_retval, GLFWcharfun_cb_args],
367
+ :GLFWcharmodsfun => [GLFWcharmodsfun_cb_retval, GLFWcharmodsfun_cb_args],
368
+ :GLFWdropfun => [GLFWdropfun_cb_retval, GLFWdropfun_cb_args],
369
+ :GLFWmonitorfun => [GLFWmonitorfun_cb_retval, GLFWmonitorfun_cb_args],
370
+ }
371
+
372
+ # Creates a callback as an instance of Fiddle::Closure::BlockCaller
373
+ def self.create_callback_closure( sym, proc=nil, &blk )
374
+ cb_retval = @@glfw_cb_closure_signature[sym][0]
375
+ cb_args = @@glfw_cb_closure_signature[sym][1]
376
+ if block_given?
377
+ return Fiddle::Closure::BlockCaller.new( cb_retval, cb_args, Fiddle::Function::DEFAULT, &blk )
378
+ else
379
+ return Fiddle::Closure::BlockCaller.new( cb_retval, cb_args, Fiddle::Function::DEFAULT, &proc )
380
+ end
381
+ end
382
+
383
+ # NOTE : Use 'create_callback_function' for backward compatibility.
384
+ def self.create_callback( sym, proc=nil, &blk )
385
+ return self.create_callback_closure( sym, proc, &blk )
386
+ end
387
+
316
388
  # struct
317
389
  GLFWvidmode = struct(["int width",
318
390
  "int height",
@@ -1,4 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
+ # A GLFW wrapper (for version 3.0)
2
3
  require 'fiddle/import'
3
4
 
4
5
  module GLFW
@@ -266,9 +267,102 @@ module GLFW
266
267
  GLFW_CONNECTED = 0x00040001
267
268
  GLFW_DISCONNECTED = 0x00040002
268
269
 
270
+ # typedefs
271
+ @@glfw_cb_function_signature = {
272
+ :GLFWerrorfun => "void GLFWerrorfun(int,const char*)",
273
+ :GLFWwindowposfun => "void GLFWwindowposfun(void*,int,int)",
274
+ :GLFWwindowsizefun => "void GLFWwindowsizefun(void*,int,int)",
275
+ :GLFWwindowclosefun => "void GLFWwindowclosefun(void*)",
276
+ :GLFWwindowrefreshfun => "void GLFWwindowrefreshfun(void*)",
277
+ :GLFWwindowfocusfun => "void GLFWwindowfocusfun(void*,int)",
278
+ :GLFWwindowiconifyfun => "void GLFWwindowiconifyfun(void*,int)",
279
+ :GLFWframebuffersizefun => "void GLFWframebuffersizefun(void*,int,int)",
280
+ :GLFWmousebuttonfun => "void GLFWmousebuttonfun(void*,int,int,int)",
281
+ :GLFWcursorposfun => "void GLFWcursorposfun(void*,double,double)",
282
+ :GLFWcursorenterfun => "void GLFWcursorenterfun(void*,int)",
283
+ :GLFWscrollfun => "void GLFWscrollfun(void*,double,double)",
284
+ :GLFWkeyfun => "void GLFWkeyfun(void*,int,int,int,int)",
285
+ :GLFWcharfun => "void GLFWcharfun(void*,unsigned int)",
286
+ :GLFWmonitorfun => "void GLFWmonitorfun(void*,int)",
287
+ }
288
+
289
+ # Creates a callback as an instance of Fiddle::Function
290
+ def self.create_callback_function( sym, proc=nil, &blk )
291
+ if block_given?
292
+ return bind( @@glfw_cb_function_signature[sym], nil, &blk )
293
+ else
294
+ return bind( @@glfw_cb_function_signature[sym], nil, &proc )
295
+ end
296
+ end
297
+
298
+ GLFWerrorfun_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_VOIDP]
299
+ GLFWerrorfun_cb_retval = Fiddle::TYPE_VOID
300
+ GLFWwindowposfun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
301
+ GLFWwindowposfun_cb_retval = Fiddle::TYPE_VOID
302
+ GLFWwindowsizefun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
303
+ GLFWwindowsizefun_cb_retval = Fiddle::TYPE_VOID
304
+ GLFWwindowclosefun_cb_args = [Fiddle::TYPE_VOIDP]
305
+ GLFWwindowclosefun_cb_retval = Fiddle::TYPE_VOID
306
+ GLFWwindowrefreshfun_cb_args = [Fiddle::TYPE_VOIDP]
307
+ GLFWwindowrefreshfun_cb_retval = Fiddle::TYPE_VOID
308
+ GLFWwindowfocusfun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT]
309
+ GLFWwindowfocusfun_cb_retval = Fiddle::TYPE_VOID
310
+ GLFWwindowiconifyfun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT]
311
+ GLFWwindowiconifyfun_cb_retval = Fiddle::TYPE_VOID
312
+ GLFWframebuffersizefun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
313
+ GLFWframebuffersizefun_cb_retval = Fiddle::TYPE_VOID
314
+ GLFWmousebuttonfun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
315
+ GLFWmousebuttonfun_cb_retval = Fiddle::TYPE_VOID
316
+ GLFWcursorposfun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_DOUBLE, Fiddle::TYPE_DOUBLE]
317
+ GLFWcursorposfun_cb_retval = Fiddle::TYPE_VOID
318
+ GLFWcursorenterfun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT]
319
+ GLFWcursorenterfun_cb_retval = Fiddle::TYPE_VOID
320
+ GLFWscrollfun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_DOUBLE, Fiddle::TYPE_DOUBLE]
321
+ GLFWscrollfun_cb_retval = Fiddle::TYPE_VOID
322
+ GLFWkeyfun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
323
+ GLFWkeyfun_cb_retval = Fiddle::TYPE_VOID
324
+ GLFWcharfun_cb_args = [Fiddle::TYPE_VOIDP, -Fiddle::TYPE_INT]
325
+ GLFWcharfun_cb_retval = Fiddle::TYPE_VOID
326
+ GLFWmonitorfun_cb_args = [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT]
327
+ GLFWmonitorfun_cb_retval = Fiddle::TYPE_VOID
328
+
329
+ @@glfw_cb_closure_signature = {
330
+ :GLFWerrorfun => [GLFWerrorfun_cb_retval, GLFWerrorfun_cb_args],
331
+ :GLFWwindowposfun => [GLFWwindowposfun_cb_retval, GLFWwindowposfun_cb_args],
332
+ :GLFWwindowsizefun => [GLFWwindowsizefun_cb_retval, GLFWwindowsizefun_cb_args],
333
+ :GLFWwindowclosefun => [GLFWwindowclosefun_cb_retval, GLFWwindowclosefun_cb_args],
334
+ :GLFWwindowrefreshfun => [GLFWwindowrefreshfun_cb_retval, GLFWwindowrefreshfun_cb_args],
335
+ :GLFWwindowfocusfun => [GLFWwindowfocusfun_cb_retval, GLFWwindowfocusfun_cb_args],
336
+ :GLFWwindowiconifyfun => [GLFWwindowiconifyfun_cb_retval, GLFWwindowiconifyfun_cb_args],
337
+ :GLFWframebuffersizefun => [GLFWframebuffersizefun_cb_retval, GLFWframebuffersizefun_cb_args],
338
+ :GLFWmousebuttonfun => [GLFWmousebuttonfun_cb_retval, GLFWmousebuttonfun_cb_args],
339
+ :GLFWcursorposfun => [GLFWcursorposfun_cb_retval, GLFWcursorposfun_cb_args],
340
+ :GLFWcursorenterfun => [GLFWcursorenterfun_cb_retval, GLFWcursorenterfun_cb_args],
341
+ :GLFWscrollfun => [GLFWscrollfun_cb_retval, GLFWscrollfun_cb_args],
342
+ :GLFWkeyfun => [GLFWkeyfun_cb_retval, GLFWkeyfun_cb_args],
343
+ :GLFWcharfun => [GLFWcharfun_cb_retval, GLFWcharfun_cb_args],
344
+ :GLFWmonitorfun => [GLFWmonitorfun_cb_retval, GLFWmonitorfun_cb_args],
345
+ }
346
+
347
+ # Creates a callback as an instance of Fiddle::Closure::BlockCaller
348
+ def self.create_callback_closure( sym, proc=nil, &blk )
349
+ cb_retval = @@glfw_cb_closure_signature[sym][0]
350
+ cb_args = @@glfw_cb_closure_signature[sym][1]
351
+ if block_given?
352
+ return Fiddle::Closure::BlockCaller.new( cb_retval, cb_args, Fiddle::Function::DEFAULT, &blk )
353
+ else
354
+ return Fiddle::Closure::BlockCaller.new( cb_retval, cb_args, Fiddle::Function::DEFAULT, &proc )
355
+ end
356
+ end
357
+
358
+ # NOTE : Use 'create_callback_function' for backward compatibility.
359
+ def self.create_callback( sym, proc=nil, &blk )
360
+ return self.create_callback_closure( sym, proc, &blk )
361
+ end
362
+
363
+
269
364
  # typedefs
270
365
  @@glfw_cb_signature = {
271
- :GLFWglproc => "void GLFWglproc()",
272
366
  :GLFWerrorfun => "void GLFWerrorfun(int,const char*)",
273
367
  :GLFWwindowposfun => "void GLFWwindowposfun(void*,int,int)",
274
368
  :GLFWwindowsizefun => "void GLFWwindowsizefun(void*,int,int)",
@@ -1,4 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
+ # A FreeGLUT wrapper
2
3
  require 'fiddle/import'
3
4
  require_relative 'opengl_platform'
4
5
 
@@ -218,7 +219,7 @@ module GLUT
218
219
  GLUT_GAME_MODE_DISPLAY_CHANGED = 0x0006
219
220
 
220
221
  # typedefs
221
- @@glut_cb_signature = {
222
+ @@glut_cb_function_signature = {
222
223
  :GLUTMenuFunc => "void GLUTMenuFunc(int)",
223
224
 
224
225
  :GLUTTimerFunc => "void GLUTTimerFunc(int)",
@@ -251,14 +252,113 @@ module GLUT
251
252
  :GLUTTabletButtonFunc => "void GLUTTabletButtonFunc(int, int, int, int)",
252
253
  }
253
254
 
255
+ # Creates a callback as an instance of Fiddle::Function
254
256
  def self.create_callback( sym, proc=nil, &blk )
255
257
  if block_given?
256
- return bind( @@glut_cb_signature[sym], nil, &blk )
258
+ return bind( @@glut_cb_function_signature[sym], nil, &blk )
257
259
  else
258
- return bind( @@glut_cb_signature[sym], nil, &proc )
260
+ return bind( @@glut_cb_function_signature[sym], nil, &proc )
259
261
  end
260
262
  end
261
263
 
264
+ GLUTMenuFunc_cb_args = [Fiddle::TYPE_INT]
265
+ GLUTMenuFunc_cb_retval = Fiddle::TYPE_VOID
266
+ GLUTTimerFunc_cb_args = [Fiddle::TYPE_INT]
267
+ GLUTTimerFunc_cb_retval = Fiddle::TYPE_VOID
268
+ GLUTIdleFunc_cb_args = []
269
+ GLUTIdleFunc_cb_retval = Fiddle::TYPE_VOID
270
+ GLUTKeyboardFunc_cb_args = [-Fiddle::TYPE_CHAR, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
271
+ GLUTKeyboardFunc_cb_retval = Fiddle::TYPE_VOID
272
+ GLUTSpecialFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
273
+ GLUTSpecialFunc_cb_retval = Fiddle::TYPE_VOID
274
+ GLUTReshapeFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT]
275
+ GLUTReshapeFunc_cb_retval = Fiddle::TYPE_VOID
276
+ GLUTVisibilityFunc_cb_args = [Fiddle::TYPE_INT]
277
+ GLUTVisibilityFunc_cb_retval = Fiddle::TYPE_VOID
278
+ GLUTDisplayFunc_cb_args = []
279
+ GLUTDisplayFunc_cb_retval = Fiddle::TYPE_VOID
280
+ GLUTMouseFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
281
+ GLUTMouseFunc_cb_retval = Fiddle::TYPE_VOID
282
+ GLUTMotionFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT]
283
+ GLUTMotionFunc_cb_retval = Fiddle::TYPE_VOID
284
+ GLUTPassiveMotionFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT]
285
+ GLUTPassiveMotionFunc_cb_retval = Fiddle::TYPE_VOID
286
+ GLUTEntryFunc_cb_args = [Fiddle::TYPE_INT]
287
+ GLUTEntryFunc_cb_retval = Fiddle::TYPE_VOID
288
+ GLUTKeyboardUpFunc_cb_args = [-Fiddle::TYPE_CHAR, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
289
+ GLUTKeyboardUpFunc_cb_retval = Fiddle::TYPE_VOID
290
+ GLUTSpecialUpFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
291
+ GLUTSpecialUpFunc_cb_retval = Fiddle::TYPE_VOID
292
+ GLUTJoystickFunc_cb_args = [-Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
293
+ GLUTJoystickFunc_cb_retval = Fiddle::TYPE_VOID
294
+ GLUTMenuStateFunc_cb_args = [Fiddle::TYPE_INT]
295
+ GLUTMenuStateFunc_cb_retval = Fiddle::TYPE_VOID
296
+ GLUTMenuStatusFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
297
+ GLUTMenuStatusFunc_cb_retval = Fiddle::TYPE_VOID
298
+ GLUTOverlayDisplayFunc_cb_args = []
299
+ GLUTOverlayDisplayFunc_cb_retval = Fiddle::TYPE_VOID
300
+ GLUTWindowStatusFunc_cb_args = [Fiddle::TYPE_INT]
301
+ GLUTWindowStatusFunc_cb_retval = Fiddle::TYPE_VOID
302
+ GLUTSpaceballMotionFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
303
+ GLUTSpaceballMotionFunc_cb_retval = Fiddle::TYPE_VOID
304
+ GLUTSpaceballRotateFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
305
+ GLUTSpaceballRotateFunc_cb_retval = Fiddle::TYPE_VOID
306
+ GLUTSpaceballButtonFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT]
307
+ GLUTSpaceballButtonFunc_cb_retval = Fiddle::TYPE_VOID
308
+ GLUTButtonBoxFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT]
309
+ GLUTButtonBoxFunc_cb_retval = Fiddle::TYPE_VOID
310
+ GLUTDialsFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT]
311
+ GLUTDialsFunc_cb_retval = Fiddle::TYPE_VOID
312
+ GLUTTabletMotionFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT]
313
+ GLUTTabletMotionFunc_cb_retval = Fiddle::TYPE_VOID
314
+ GLUTTabletButtonFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
315
+ GLUTTabletButtonFunc_cb_retval = Fiddle::TYPE_VOID
316
+
317
+ @@glut_cb_closure_signature = {
318
+ :GLUTMenuFunc => [GLUTMenuFunc_cb_retval, GLUTMenuFunc_cb_args],
319
+ :GLUTTimerFunc => [GLUTTimerFunc_cb_retval, GLUTTimerFunc_cb_args],
320
+ :GLUTIdleFunc => [GLUTIdleFunc_cb_retval, GLUTIdleFunc_cb_args],
321
+ :GLUTKeyboardFunc => [GLUTKeyboardFunc_cb_retval, GLUTKeyboardFunc_cb_args],
322
+ :GLUTSpecialFunc => [GLUTSpecialFunc_cb_retval, GLUTSpecialFunc_cb_args],
323
+ :GLUTReshapeFunc => [GLUTReshapeFunc_cb_retval, GLUTReshapeFunc_cb_args],
324
+ :GLUTVisibilityFunc => [GLUTVisibilityFunc_cb_retval, GLUTVisibilityFunc_cb_args],
325
+ :GLUTDisplayFunc => [GLUTDisplayFunc_cb_retval, GLUTDisplayFunc_cb_args],
326
+ :GLUTMouseFunc => [GLUTMouseFunc_cb_retval, GLUTMouseFunc_cb_args],
327
+ :GLUTMotionFunc => [GLUTMotionFunc_cb_retval, GLUTMotionFunc_cb_args],
328
+ :GLUTPassiveMotionFunc => [GLUTPassiveMotionFunc_cb_retval, GLUTPassiveMotionFunc_cb_args],
329
+ :GLUTEntryFunc => [GLUTEntryFunc_cb_retval, GLUTEntryFunc_cb_args],
330
+ :GLUTKeyboardUpFunc => [GLUTKeyboardUpFunc_cb_retval, GLUTKeyboardUpFunc_cb_args],
331
+ :GLUTSpecialUpFunc => [GLUTSpecialUpFunc_cb_retval, GLUTSpecialUpFunc_cb_args],
332
+ :GLUTJoystickFunc => [GLUTJoystickFunc_cb_retval, GLUTJoystickFunc_cb_args],
333
+ :GLUTMenuStateFunc => [GLUTMenuStateFunc_cb_retval, GLUTMenuStateFunc_cb_args],
334
+ :GLUTMenuStatusFunc => [GLUTMenuStatusFunc_cb_retval, GLUTMenuStatusFunc_cb_args],
335
+ :GLUTOverlayDisplayFunc => [GLUTOverlayDisplayFunc_cb_retval, GLUTOverlayDisplayFunc_cb_args],
336
+ :GLUTWindowStatusFunc => [GLUTWindowStatusFunc_cb_retval, GLUTWindowStatusFunc_cb_args],
337
+ :GLUTSpaceballMotionFunc => [GLUTSpaceballMotionFunc_cb_retval, GLUTSpaceballMotionFunc_cb_args],
338
+ :GLUTSpaceballRotateFunc => [GLUTSpaceballRotateFunc_cb_retval, GLUTSpaceballRotateFunc_cb_args],
339
+ :GLUTSpaceballButtonFunc => [GLUTSpaceballButtonFunc_cb_retval, GLUTSpaceballButtonFunc_cb_args],
340
+ :GLUTButtonBoxFunc => [GLUTButtonBoxFunc_cb_retval, GLUTButtonBoxFunc_cb_args],
341
+ :GLUTDialsFunc => [GLUTDialsFunc_cb_retval, GLUTDialsFunc_cb_args],
342
+ :GLUTTabletMotionFunc => [GLUTTabletMotionFunc_cb_retval, GLUTTabletMotionFunc_cb_args],
343
+ :GLUTTabletButtonFunc => [GLUTTabletButtonFunc_cb_retval, GLUTTabletButtonFunc_cb_args],
344
+ }
345
+
346
+ # Creates a callback as an instance of Fiddle::Closure::BlockCaller
347
+ def self.create_callback_closure( sym, proc=nil, &blk )
348
+ cb_retval = @@glut_cb_closure_signature[sym][0]
349
+ cb_args = @@glut_cb_closure_signature[sym][1]
350
+ if block_given?
351
+ return Fiddle::Closure::BlockCaller.new( cb_retval, cb_args, Fiddle::Function::DEFAULT, &blk )
352
+ else
353
+ return Fiddle::Closure::BlockCaller.new( cb_retval, cb_args, Fiddle::Function::DEFAULT, &proc )
354
+ end
355
+ end
356
+
357
+ # NOTE : Use 'create_callback_function' for backward compatibility.
358
+ def self.create_callback( sym, proc=nil, &blk )
359
+ return self.create_callback_closure( sym, proc, &blk )
360
+ end
361
+
262
362
  @@glut_import_done = false
263
363
 
264
364
  # Load native library.
metadata CHANGED
@@ -1,17 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opengl-bindings
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - vaiorabbit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-21 00:00:00.000000000 Z
11
+ date: 2015-12-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: |
14
- Ruby bindings for OpenGL - 4.5, OpenGL ES - 3.2 and all extensions using Fiddle (For MRI >= 2.0.0). GLFW/GLUT/GLU bindings are also available.
13
+ description: 'Ruby bindings for OpenGL - 4.5, OpenGL ES - 3.2 and all extensions using
14
+ Fiddle (For MRI >= 2.0.0). GLFW/GLUT/GLU bindings are also available.
15
+
16
+ '
15
17
  email:
16
18
  - vaiorabbit@gmail.com
17
19
  executables: []