ruby-opengl 0.50.0 → 0.60.0

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.
Files changed (118) hide show
  1. data/Rakefile +15 -11
  2. data/doc/build_install.txt +10 -6
  3. data/doc/extensions.txt.in +348 -0
  4. data/doc/history.txt +4 -0
  5. data/doc/roadmap.txt +4 -6
  6. data/doc/scientific_use.txt +7 -0
  7. data/doc/supplies/page_template.html +2 -1
  8. data/doc/thanks.txt +5 -0
  9. data/doc/tutorial.txt +431 -121
  10. data/examples/NeHe/nehe_lesson02.rb +1 -1
  11. data/examples/NeHe/nehe_lesson03.rb +1 -1
  12. data/examples/NeHe/nehe_lesson04.rb +1 -1
  13. data/examples/NeHe/nehe_lesson05.rb +1 -1
  14. data/examples/NeHe/nehe_lesson36.rb +1 -1
  15. data/examples/OrangeBook/brick.rb +3 -15
  16. data/examples/OrangeBook/particle.rb +2 -20
  17. data/examples/RedBook/aapoly.rb +1 -1
  18. data/examples/RedBook/aargb.rb +2 -2
  19. data/examples/RedBook/accanti.rb +1 -1
  20. data/examples/RedBook/accpersp.rb +1 -1
  21. data/examples/RedBook/alpha.rb +2 -2
  22. data/examples/RedBook/alpha3D.rb +1 -1
  23. data/examples/RedBook/bezcurve.rb +1 -1
  24. data/examples/RedBook/bezmesh.rb +1 -1
  25. data/examples/RedBook/checker.rb +1 -1
  26. data/examples/RedBook/clip.rb +1 -1
  27. data/examples/RedBook/colormat.rb +1 -1
  28. data/examples/RedBook/cube.rb +1 -1
  29. data/examples/RedBook/depthcue.rb +1 -1
  30. data/examples/RedBook/dof.rb +1 -1
  31. data/examples/RedBook/double.rb +1 -1
  32. data/examples/RedBook/drawf.rb +1 -1
  33. data/examples/RedBook/feedback.rb +1 -1
  34. data/examples/RedBook/fog.rb +1 -1
  35. data/examples/RedBook/font.rb +2 -2
  36. data/examples/RedBook/hello.rb +1 -1
  37. data/examples/RedBook/image.rb +4 -4
  38. data/examples/RedBook/lines.rb +1 -1
  39. data/examples/RedBook/list.rb +1 -1
  40. data/examples/RedBook/material.rb +1 -1
  41. data/examples/RedBook/mipmap.rb +1 -1
  42. data/examples/RedBook/model.rb +1 -1
  43. data/examples/RedBook/movelight.rb +1 -1
  44. data/examples/RedBook/pickdepth.rb +1 -1
  45. data/examples/RedBook/planet.rb +5 -5
  46. data/examples/RedBook/quadric.rb +1 -1
  47. data/examples/RedBook/robot.rb +5 -5
  48. data/examples/RedBook/select.rb +1 -1
  49. data/examples/RedBook/smooth.rb +1 -1
  50. data/examples/RedBook/stencil.rb +1 -1
  51. data/examples/RedBook/stroke.rb +2 -2
  52. data/examples/RedBook/surface.rb +1 -1
  53. data/examples/RedBook/teaambient.rb +1 -1
  54. data/examples/RedBook/teapots.rb +1 -1
  55. data/examples/RedBook/tess.rb +1 -1
  56. data/examples/RedBook/texbind.rb +1 -1
  57. data/examples/RedBook/texgen.rb +5 -5
  58. data/examples/RedBook/texturesurf.rb +1 -1
  59. data/examples/RedBook/varray.rb +1 -1
  60. data/examples/RedBook/wrap.rb +5 -5
  61. data/examples/misc/OGLBench.rb +337 -0
  62. data/examples/misc/anisotropic.rb +1 -1
  63. data/examples/misc/fbo_test.rb +356 -0
  64. data/examples/misc/font-glut.rb +1 -1
  65. data/examples/misc/glfwtest.rb +30 -0
  66. data/examples/misc/md2model.rb +15 -0
  67. data/examples/misc/plane.rb +1 -1
  68. data/examples/misc/readpixel.rb +1 -1
  69. data/examples/misc/sdltest.rb +34 -0
  70. data/examples/misc/trislam.rb +828 -0
  71. data/ext/common/common.h +126 -218
  72. data/ext/common/conv.h +244 -0
  73. data/ext/common/funcdef.h +280 -0
  74. data/ext/common/gl-error.h +23 -0
  75. data/ext/common/gl-types.h +14 -0
  76. data/ext/gl/gl-1.0-1.1.c +497 -1255
  77. data/ext/gl/gl-1.2.c +121 -304
  78. data/ext/gl/gl-1.3.c +78 -339
  79. data/ext/gl/gl-1.4.c +102 -164
  80. data/ext/gl/gl-1.5.c +42 -173
  81. data/ext/gl/gl-2.0.c +273 -1039
  82. data/ext/gl/gl-2.1.c +15 -19
  83. data/ext/gl/gl-enums.c +3 -2
  84. data/ext/gl/gl-error.c +104 -0
  85. data/ext/gl/gl-ext-3dfx.c +27 -0
  86. data/ext/gl/gl-ext-arb.c +812 -12
  87. data/ext/gl/gl-ext-ati.c +41 -0
  88. data/ext/gl/gl-ext-ext.c +791 -119
  89. data/ext/gl/gl-ext-gremedy.c +41 -0
  90. data/ext/gl/gl-ext-nv.c +679 -0
  91. data/ext/gl/gl.c +48 -28
  92. data/ext/gl/mkrf_conf.rb +13 -10
  93. data/ext/glu/glu-enums.c +3 -2
  94. data/ext/glu/glu.c +136 -41
  95. data/ext/glu/mkrf_conf.rb +15 -12
  96. data/ext/glut/glut.c +37 -80
  97. data/ext/glut/mkrf_conf.rb +17 -13
  98. data/lib/opengl.rb +29 -53
  99. data/test/tc_common.rb +9 -3
  100. data/test/tc_ext_arb.rb +397 -3
  101. data/test/tc_ext_ati.rb +33 -0
  102. data/test/tc_ext_ext.rb +479 -2
  103. data/test/tc_ext_gremedy.rb +36 -0
  104. data/test/tc_ext_nv.rb +357 -0
  105. data/test/tc_func_10_11.rb +93 -67
  106. data/test/tc_func_12.rb +11 -11
  107. data/test/tc_func_13.rb +38 -18
  108. data/test/tc_func_14.rb +2 -2
  109. data/test/tc_func_15.rb +10 -10
  110. data/test/tc_func_20.rb +20 -20
  111. data/test/tc_func_21.rb +53 -22
  112. data/test/tc_glu.rb +9 -4
  113. data/test/tc_misc.rb +15 -2
  114. metadata +22 -8
  115. data/doc/extensions.txt +0 -361
  116. data/examples/RedBook/aaindex.rb +0 -97
  117. data/examples/misc/smooth.rb +0 -42
  118. data/examples/misc/test.rb +0 -65
@@ -16,17 +16,20 @@
16
16
  require 'rubygems'
17
17
  require 'mkrf'
18
18
 
19
+ RUBYVER = " -DRUBY_VERSION=" + RUBY_VERSION.split(".").join
20
+
19
21
  Mkrf::Generator.new( 'glu' ) do |g|
20
- case RUBY_PLATFORM
21
- when /darwin/
22
- g.ldshared << ' -framework OpenGL'
23
- when /mswin32/
24
- g.cflags << ' -DWIN32'
25
- g.include_library( 'opengl32.lib', 'glVertex3d')
26
- g.include_library( 'glu32.lib', 'gluLookAt')
27
- else
28
- g.cflags << ' -Wall'
29
- g.include_library( 'GLU', 'gluLookAt' )
30
- g.include_library( 'GL', 'glVertex3d')
31
- end
22
+ case RUBY_PLATFORM
23
+ when /darwin/
24
+ g.cflags << RUBYVER
25
+ g.ldshared << ' -framework OpenGL'
26
+ when /mswin32/
27
+ g.cflags << ' -DWIN32' + RUBYVER
28
+ g.include_library( 'opengl32.lib', 'glVertex3d')
29
+ g.include_library( 'glu32.lib', 'gluLookAt')
30
+ else
31
+ g.cflags << ' -Wall' + RUBYVER
32
+ g.include_library( 'GLU', 'gluLookAt' )
33
+ g.include_library( 'GL', 'glVertex3d')
34
+ end
32
35
  end
@@ -73,7 +73,6 @@ VALUE obj; \
73
73
  */
74
74
 
75
75
  /* GLUT initialization sub-API. */
76
- static VALUE g_arg_array;
77
76
 
78
77
  static VALUE glut_Init( int argc, VALUE * argv, VALUE obj)
79
78
  {
@@ -120,7 +119,7 @@ glut_InitDisplayString(obj,arg1)
120
119
  VALUE obj,arg1;
121
120
  {
122
121
  Check_Type(arg1,T_STRING);
123
- glutInitDisplayString(RSTRING(arg1)->ptr);
122
+ glutInitDisplayString(RSTRING_PTR(arg1));
124
123
  return Qnil;
125
124
  }
126
125
 
@@ -201,7 +200,7 @@ VALUE obj,arg1,arg2;
201
200
  int win;
202
201
  int pollinterval;
203
202
  if (!rb_obj_is_kind_of(arg1,rb_cProc) && !NIL_P(arg1))
204
- rb_raise(rb_eTypeError, "glutJoystickFunc", rb_class2name(CLASS_OF(arg1)));
203
+ rb_raise(rb_eTypeError, "glutJoystickFunc:%s", rb_class2name(CLASS_OF(arg1)));
205
204
  pollinterval=NUM2INT(arg2);
206
205
  win = glutGetWindow();
207
206
  if (win == 0)
@@ -226,7 +225,7 @@ VALUE obj;
226
225
  if (argc == 0)
227
226
  title = rb_eval_string("$0");
228
227
  Check_Type(title,T_STRING);
229
- ret = glutCreateWindow(RSTRING(title)->ptr);
228
+ ret = glutCreateWindow(RSTRING_PTR(title));
230
229
  return INT2NUM(ret);
231
230
  }
232
231
 
@@ -286,7 +285,7 @@ glut_SetWindowTitle(obj,arg1)
286
285
  VALUE obj,arg1;
287
286
  {
288
287
  Check_Type(arg1,T_STRING);
289
- glutSetWindowTitle(RSTRING(arg1)->ptr);
288
+ glutSetWindowTitle(RSTRING_PTR(arg1));
290
289
  return Qnil;
291
290
  }
292
291
 
@@ -296,7 +295,7 @@ glut_SetIconTitle(obj, arg1)
296
295
  VALUE obj,arg1;
297
296
  {
298
297
  Check_Type(arg1,T_STRING);
299
- glutSetIconTitle(RSTRING(arg1)->ptr);
298
+ glutSetIconTitle(RSTRING_PTR(arg1));
300
299
  return Qnil;
301
300
  }
302
301
 
@@ -372,15 +371,14 @@ glut_UseLayer(obj,arg1)
372
371
 
373
372
  /* GLUT menu sub-API. */
374
373
  static VALUE g_menucallback = Qnil;
375
- static VALUE g_menuargs = Qnil;
376
374
  static void GLUTCALLBACK
377
375
  glut_CreateMenuCallback(int value)
378
376
  {
379
- VALUE arg_pair;
380
377
  VALUE func;
381
- arg_pair = (VALUE)value;
382
- func = rb_hash_aref(g_menucallback, rb_ary_entry(arg_pair, 0));
383
- rb_funcall(func, callId, 1, rb_ary_entry(arg_pair, 1));
378
+ int menu;
379
+ menu = glutGetMenu();
380
+ func = rb_ary_entry(g_menucallback,menu);
381
+ rb_funcall(func, callId, 1, INT2NUM(value));
384
382
  }
385
383
 
386
384
 
@@ -389,14 +387,16 @@ glut_CreateMenu(obj,arg1)
389
387
  VALUE obj,arg1;
390
388
  {
391
389
  int menu;
392
- VALUE ret;
393
- if (!rb_obj_is_kind_of(arg1,rb_cProc))
390
+ if (!rb_obj_is_kind_of(arg1,rb_cProc) && !NIL_P(arg1))
394
391
  rb_raise(rb_eTypeError, "glutCreateMenu:%s", rb_class2name(CLASS_OF(arg1)));
395
- menu = glutCreateMenu(glut_CreateMenuCallback);
396
- ret = INT2FIX(menu);
397
- rb_hash_aset(g_menucallback, ret, arg1);
398
- rb_hash_aset(g_menuargs, ret, rb_ary_new());
399
- return ret;
392
+
393
+ if (NIL_P(arg1))
394
+ menu = glutCreateMenu(NULL);
395
+ else
396
+ menu = glutCreateMenu(glut_CreateMenuCallback);
397
+
398
+ rb_ary_store(g_menucallback,menu,arg1);
399
+ return INT2FIX(menu);
400
400
  }
401
401
 
402
402
 
@@ -407,8 +407,8 @@ VALUE obj,arg1;
407
407
  int menu;
408
408
  menu = INT2FIX(arg1);
409
409
  glutDestroyMenu(menu);
410
- rb_hash_aset(g_menucallback, menu, Qnil);
411
- rb_hash_aset(g_menuargs, menu, Qnil);
410
+ //rb_hash_aset(g_menucallback, menu, Qnil);
411
+ //rb_hash_aset(g_menuargs, menu, Qnil);
412
412
  return Qnil;
413
413
  }
414
414
 
@@ -427,9 +427,7 @@ static VALUE
427
427
  glut_SetMenu(obj,arg1)
428
428
  VALUE obj,arg1;
429
429
  {
430
- int menu;
431
- menu = NUM2INT(arg1);
432
- glutSetMenu(menu);
430
+ glutSetMenu(NUM2INT(arg1));
433
431
  return Qnil;
434
432
  }
435
433
 
@@ -438,19 +436,8 @@ static VALUE
438
436
  glut_AddMenuEntry(obj,arg1,arg2)
439
437
  VALUE obj,arg1,arg2;
440
438
  {
441
- int curmenuid;
442
- VALUE arg_ary;
443
- VALUE arg_pair;
444
439
  Check_Type(arg1,T_STRING);
445
- curmenuid = glutGetMenu();
446
- if (curmenuid == 0)
447
- rb_raise(rb_eRuntimeError, "glutAddMenuEntry needs current menu");
448
- arg_ary = rb_hash_aref(g_menuargs, INT2FIX(curmenuid));
449
- arg_pair = rb_ary_new2(2);
450
- rb_ary_store(arg_pair, 0, INT2FIX(curmenuid));
451
- rb_ary_store(arg_pair, 1, arg2);
452
- rb_ary_push(arg_ary, arg_pair);
453
- glutAddMenuEntry(RSTRING(arg1)->ptr, arg_pair);
440
+ glutAddMenuEntry(RSTRING_PTR(arg1), NUM2INT(arg2));
454
441
  return Qnil;
455
442
  }
456
443
 
@@ -459,10 +446,8 @@ static VALUE
459
446
  glut_AddSubMenu(obj,arg1,arg2)
460
447
  VALUE obj,arg1,arg2;
461
448
  {
462
- int value;
463
449
  Check_Type(arg1,T_STRING);
464
- value = NUM2INT(arg2);
465
- glutAddSubMenu(RSTRING(arg1)->ptr, value);
450
+ glutAddSubMenu(RSTRING_PTR(arg1), NUM2INT(arg2));
466
451
  return Qnil;
467
452
  }
468
453
 
@@ -470,21 +455,8 @@ VALUE obj,arg1,arg2;
470
455
  static VALUE glut_ChangeToMenuEntry(obj,arg1,arg2,arg3)
471
456
  VALUE obj,arg1,arg2,arg3;
472
457
  {
473
- VALUE arg_ary;
474
- VALUE arg_pair;
475
- int item;
476
- int curmenuid;
477
- item = NUM2INT(arg1);
478
458
  Check_Type(arg2,T_STRING);
479
- curmenuid = glutGetMenu();
480
- if (curmenuid == 0)
481
- rb_raise(rb_eRuntimeError, "glutChangeToMenuEntry needs current menu");
482
- arg_ary = rb_hash_aref(g_menuargs, INT2FIX(curmenuid));
483
- arg_pair = rb_ary_new2(2);
484
- rb_ary_store(arg_pair, 0, INT2FIX(curmenuid));
485
- rb_ary_store(arg_pair, 1, arg2);
486
- rb_ary_store(arg_ary, item, arg_pair);
487
- glutChangeToMenuEntry(item, RSTRING(arg2)->ptr, arg_pair);
459
+ glutChangeToMenuEntry(NUM2INT(arg1), RSTRING_PTR(arg2), NUM2INT(arg3));
488
460
  return Qnil;
489
461
  }
490
462
 
@@ -492,27 +464,15 @@ VALUE obj,arg1,arg2,arg3;
492
464
  static VALUE glut_ChangeToSubMenu(obj,arg1,arg2,arg3)
493
465
  VALUE obj,arg1,arg2,arg3;
494
466
  {
495
- int item,submenu;
496
- item = NUM2INT(arg1);
497
- submenu = NUM2INT(arg3);
498
467
  Check_Type(arg2,T_STRING);
499
- glutChangeToSubMenu(item, RSTRING(arg2)->ptr, submenu);
468
+ glutChangeToSubMenu(NUM2INT(arg1), RSTRING_PTR(arg2), NUM2INT(arg3));
500
469
  return Qnil;
501
470
  }
502
471
 
503
472
 
504
473
  static VALUE glut_RemoveMenuItem( VALUE obj, VALUE arg1 )
505
474
  {
506
- int item;
507
- int curmenuid;
508
- VALUE arg_ary;
509
- item = NUM2INT(arg1);
510
- glutRemoveMenuItem(item);
511
- curmenuid = glutGetMenu();
512
- if (curmenuid == 0)
513
- rb_raise(rb_eRuntimeError, "glutRemoveMenuItem needs current menu");
514
- arg_ary = rb_hash_aref(g_menuargs, INT2FIX(curmenuid));
515
- rb_ary_delete(arg_ary, item);
475
+ glutRemoveMenuItem(NUM2INT(arg1));
516
476
  return Qnil;
517
477
  }
518
478
 
@@ -521,9 +481,7 @@ static VALUE
521
481
  glut_AttachMenu(obj,arg1)
522
482
  VALUE obj, arg1;
523
483
  {
524
- int button;
525
- button = NUM2INT(arg1);
526
- glutAttachMenu(button);
484
+ glutAttachMenu(NUM2INT(arg1));
527
485
  return Qnil;
528
486
  }
529
487
 
@@ -532,9 +490,7 @@ static VALUE
532
490
  glut_DetachMenu(obj,arg1)
533
491
  VALUE obj, arg1;
534
492
  {
535
- int button;
536
- button = NUM2INT(arg1);
537
- glutDetachMenu(button);
493
+ glutDetachMenu(NUM2INT(arg1));
538
494
  return Qnil;
539
495
  }
540
496
 
@@ -568,7 +524,11 @@ int x,y;
568
524
  VALUE func;
569
525
  func = rb_ary_entry(KeyboardFunc, glutGetWindow());
570
526
  if (!NIL_P(func))
527
+ #if RUBY_VERSION <190
571
528
  rb_funcall(func, callId, 3, INT2FIX(key), INT2FIX(x), INT2FIX(y));
529
+ #else
530
+ rb_funcall(func, callId, 3, rb_funcall(INT2FIX(key),rb_intern("chr"),0), INT2FIX(x), INT2FIX(y));
531
+ #endif
572
532
  }
573
533
 
574
534
 
@@ -939,7 +899,7 @@ VALUE obj,arg1;
939
899
  {
940
900
  int ret;
941
901
  Check_Type(arg1,T_STRING);
942
- ret = glutExtensionSupported(RSTRING(arg1)->ptr);
902
+ ret = glutExtensionSupported(RSTRING_PTR(arg1));
943
903
  return INT2NUM(ret);
944
904
  }
945
905
 
@@ -1060,7 +1020,7 @@ VALUE obj,arg1,arg2;
1060
1020
  int ret;
1061
1021
  Check_Type(arg2,T_STRING);
1062
1022
  font = NUM2INT(arg1);
1063
- ret = glutBitmapLength(bitmap_font_map(font), (const unsigned char*)RSTRING(arg2)->ptr);
1023
+ ret = glutBitmapLength(bitmap_font_map(font), (const unsigned char*)RSTRING_PTR(arg2));
1064
1024
  return INT2NUM(ret);
1065
1025
  }
1066
1026
 
@@ -1073,7 +1033,7 @@ VALUE obj,arg1,arg2;
1073
1033
  int ret;
1074
1034
  Check_Type(arg2,T_STRING);
1075
1035
  font = NUM2INT(arg1);
1076
- ret = glutStrokeLength(stroke_font_map(font), (const unsigned char*)RSTRING(arg2)->ptr);
1036
+ ret = glutStrokeLength(stroke_font_map(font), (const unsigned char*)RSTRING_PTR(arg2));
1077
1037
  return INT2NUM(ret);
1078
1038
  }
1079
1039
 
@@ -1284,7 +1244,7 @@ glut_GameModeString(obj,arg1)
1284
1244
  VALUE obj,arg1;
1285
1245
  {
1286
1246
  Check_Type(arg1,T_STRING);
1287
- glutGameModeString((const char*)RSTRING(arg1)->ptr);
1247
+ glutGameModeString((const char*)RSTRING_PTR(arg1));
1288
1248
  return Qnil;
1289
1249
  }
1290
1250
 
@@ -1350,11 +1310,8 @@ DLLEXPORT void Init_glut()
1350
1310
  {
1351
1311
  module = rb_define_module("Glut");
1352
1312
 
1353
- rb_global_variable( &g_arg_array );
1354
1313
  rb_global_variable( &g_menucallback );
1355
- rb_global_variable( &g_menuargs );
1356
- g_menucallback = rb_hash_new();
1357
- g_menuargs = rb_hash_new();
1314
+ g_menucallback = rb_ary_new();
1358
1315
 
1359
1316
  rb_define_module_function(module, "glutInit", glut_Init, -1);
1360
1317
  rb_define_module_function(module, "glutInitDisplayMode", glut_InitDisplayMode, 1);
@@ -16,18 +16,22 @@
16
16
  require 'rubygems'
17
17
  require 'mkrf'
18
18
 
19
+ RUBYVER = " -DRUBY_VERSION=" + RUBY_VERSION.split(".").join
20
+
19
21
  Mkrf::Generator.new( 'glut' ) do |g|
20
- case RUBY_PLATFORM
21
- when /darwin/
22
- g.ldshared << ' -framework GLUT -framework OpenGL -framework Cocoa'
23
- when /mswin32/
24
- g.cflags << ' -DWIN32'
25
- g.include_library( 'glut32.lib', 'glutSolidTeapot' )
26
- g.include_library( 'glu32.lib', 'gluLookAt' )
27
- g.include_library( 'opengl32.lib', 'glVertex3d' )
28
- else
29
- g.include_library( 'glut', 'glutSolidTeapot' )
30
- g.include_library( 'GLU', 'gluLookAt' )
31
- g.include_library( 'GL', 'glVertex3d')
32
- end
22
+ case RUBY_PLATFORM
23
+ when /darwin/
24
+ g.cflags << RUBYVER
25
+ g.ldshared << ' -framework GLUT -framework OpenGL -framework Cocoa'
26
+ when /mswin32/
27
+ g.cflags << ' -DWIN32' + RUBYVER
28
+ g.include_library( 'glut32.lib', 'glutSolidTeapot' )
29
+ g.include_library( 'glu32.lib', 'gluLookAt' )
30
+ g.include_library( 'opengl32.lib', 'glVertex3d' )
31
+ else
32
+ g.cflags << RUBYVER
33
+ g.include_library( 'glut', 'glutSolidTeapot' )
34
+ g.include_library( 'GLU', 'gluLookAt' )
35
+ g.include_library( 'GL', 'glVertex3d')
36
+ end
33
37
  end
@@ -37,72 +37,48 @@ module GL
37
37
  # due to ruby naming scheme, we can't export constants with leading decimal,
38
38
  # e.g. (Gl::)GL_2D would under old syntax become (GL::)2D which is illegal
39
39
  next if n =~ /^[0-9]/
40
- begin
41
- const_set( n, Gl.const_get( cn ) )
42
- rescue
43
- puts "=== #{__FILE__} FAILED on Constant: #{cn} --> #{n}"
44
- end
40
+ const_set( n, Gl.const_get( cn ) )
45
41
  end
46
42
 
47
43
  Gl.methods( false ).each do |mn|
48
44
  n = mn.to_s.sub(/^gl/,'')
49
- begin
50
- alias_method( n, mn )
51
- public( n )
52
- rescue
53
- puts "=== #{__FILE__} FAILED on Method: #{mn} --> #{n}"
54
- end
45
+ alias_method( n, mn )
46
+ public( n )
55
47
  end
56
48
  end
57
49
 
58
50
  # (Glu.)gluSphere -> GLU.Sphere
59
51
  # (Glu::)GLU_INSIDE -> GLU::INSIDE
60
52
  module GLU
61
- extend self
62
- include Glu
63
-
64
- Glu.constants.each do |cn|
65
- n = cn.to_s.sub(/^GLU_/,'')
66
- begin
67
- const_set( n, Glu.const_get( cn ) )
68
- rescue
69
- puts "=== #{__FILE__} FAILED on Constant: #{cn} --> #{n}"
70
- end
71
- end
72
-
73
- Glu.methods( false ).each do |mn|
74
- n = mn.to_s.sub(/^glu/,'')
75
- begin
76
- alias_method( n, mn )
77
- public( n )
78
- rescue
79
- puts "=== #{__FILE__} FAILED on Method: #{mn} --> #{n}"
80
- end
81
- end
53
+ extend self
54
+ include Glu
55
+
56
+ Glu.constants.each do |cn|
57
+ n = cn.to_s.sub(/^GLU_/,'')
58
+ const_set( n, Glu.const_get( cn ) )
59
+ end
60
+
61
+ Glu.methods( false ).each do |mn|
62
+ n = mn.to_s.sub(/^glu/,'')
63
+ alias_method( n, mn )
64
+ public( n )
65
+ end
82
66
  end
83
67
 
84
68
  # (Glut.)glutInit -> GLUT.Init
85
69
  # (Glut::)GLUT_RGBA -> GLUT::RGBA
86
70
  module GLUT
87
- extend self
88
- include Glut
89
-
90
- Glut.constants.each do |cn|
91
- n = cn.to_s.sub(/^GLUT_/,'')
92
- begin
93
- const_set( n, Glut.const_get( cn ) )
94
- rescue
95
- puts "=== #{__FILE__} FAILED on Constant: #{cn} --> #{n}"
96
- end
97
- end
98
-
99
- Glut.methods( false ).each do |mn|
100
- n = mn.to_s.sub(/^glut/,'')
101
- begin
102
- alias_method( n, mn )
103
- public( n )
104
- rescue
105
- puts "=== #{__FILE__} FAILED on Method: #{mn} --> #{n}"
106
- end
107
- end
71
+ extend self
72
+ include Glut
73
+
74
+ Glut.constants.each do |cn|
75
+ n = cn.to_s.sub(/^GLUT_/,'')
76
+ const_set( n, Glut.const_get( cn ) )
77
+ end
78
+
79
+ Glut.methods( false ).each do |mn|
80
+ n = mn.to_s.sub(/^glut/,'')
81
+ alias_method( n, mn )
82
+ public( n )
83
+ end
108
84
  end
@@ -22,9 +22,12 @@ end
22
22
  require 'test/unit'
23
23
  require 'gl'
24
24
  require 'glut'
25
+ require 'matrix'
25
26
  include Gl
26
27
  include Glut
27
28
 
29
+ Gl.enable_error_checking
30
+
28
31
  $window_size = 512
29
32
 
30
33
  def glut_init()
@@ -37,8 +40,9 @@ def glut_init()
37
40
  glutInitWindowPosition(1, 1)
38
41
  glutInitWindowSize($window_size, $window_size)
39
42
  glutCreateWindow("test")
40
- glutDisplayFunc(display_func)
43
+
41
44
  # hack the need to call glutMainLoop on some implementations
45
+ glutDisplayFunc(display_func)
42
46
  begin
43
47
  glutMainLoop()
44
48
  rescue
@@ -75,16 +79,18 @@ end
75
79
  def common_teardown
76
80
  glPopAttrib()
77
81
  glPopClientAttrib()
82
+ glRenderMode(GL_RENDER)
83
+ # in case there is an GL error that escaped error checking routines ...
78
84
  error = glGetError()
79
85
  p gluErrorString(error) if (error!=0)
80
- assert_equal(error,0) # all expected GL errors must be handled by the method itself
86
+ assert_equal(error,0)
81
87
  end
82
88
 
83
89
  def supported?(funcs)
84
90
  Array(funcs).each do |name| # convert to array if it isn't already
85
91
  if !Gl.is_available?(name)
86
92
  puts ""
87
- puts "#{name} not supported, test skipped"
93
+ print "#{name} not supported, test skipped"
88
94
  return false
89
95
  end
90
96
  end