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.
- data/Rakefile +15 -11
- data/doc/build_install.txt +10 -6
- data/doc/extensions.txt.in +348 -0
- data/doc/history.txt +4 -0
- data/doc/roadmap.txt +4 -6
- data/doc/scientific_use.txt +7 -0
- data/doc/supplies/page_template.html +2 -1
- data/doc/thanks.txt +5 -0
- data/doc/tutorial.txt +431 -121
- data/examples/NeHe/nehe_lesson02.rb +1 -1
- data/examples/NeHe/nehe_lesson03.rb +1 -1
- data/examples/NeHe/nehe_lesson04.rb +1 -1
- data/examples/NeHe/nehe_lesson05.rb +1 -1
- data/examples/NeHe/nehe_lesson36.rb +1 -1
- data/examples/OrangeBook/brick.rb +3 -15
- data/examples/OrangeBook/particle.rb +2 -20
- data/examples/RedBook/aapoly.rb +1 -1
- data/examples/RedBook/aargb.rb +2 -2
- data/examples/RedBook/accanti.rb +1 -1
- data/examples/RedBook/accpersp.rb +1 -1
- data/examples/RedBook/alpha.rb +2 -2
- data/examples/RedBook/alpha3D.rb +1 -1
- data/examples/RedBook/bezcurve.rb +1 -1
- data/examples/RedBook/bezmesh.rb +1 -1
- data/examples/RedBook/checker.rb +1 -1
- data/examples/RedBook/clip.rb +1 -1
- data/examples/RedBook/colormat.rb +1 -1
- data/examples/RedBook/cube.rb +1 -1
- data/examples/RedBook/depthcue.rb +1 -1
- data/examples/RedBook/dof.rb +1 -1
- data/examples/RedBook/double.rb +1 -1
- data/examples/RedBook/drawf.rb +1 -1
- data/examples/RedBook/feedback.rb +1 -1
- data/examples/RedBook/fog.rb +1 -1
- data/examples/RedBook/font.rb +2 -2
- data/examples/RedBook/hello.rb +1 -1
- data/examples/RedBook/image.rb +4 -4
- data/examples/RedBook/lines.rb +1 -1
- data/examples/RedBook/list.rb +1 -1
- data/examples/RedBook/material.rb +1 -1
- data/examples/RedBook/mipmap.rb +1 -1
- data/examples/RedBook/model.rb +1 -1
- data/examples/RedBook/movelight.rb +1 -1
- data/examples/RedBook/pickdepth.rb +1 -1
- data/examples/RedBook/planet.rb +5 -5
- data/examples/RedBook/quadric.rb +1 -1
- data/examples/RedBook/robot.rb +5 -5
- data/examples/RedBook/select.rb +1 -1
- data/examples/RedBook/smooth.rb +1 -1
- data/examples/RedBook/stencil.rb +1 -1
- data/examples/RedBook/stroke.rb +2 -2
- data/examples/RedBook/surface.rb +1 -1
- data/examples/RedBook/teaambient.rb +1 -1
- data/examples/RedBook/teapots.rb +1 -1
- data/examples/RedBook/tess.rb +1 -1
- data/examples/RedBook/texbind.rb +1 -1
- data/examples/RedBook/texgen.rb +5 -5
- data/examples/RedBook/texturesurf.rb +1 -1
- data/examples/RedBook/varray.rb +1 -1
- data/examples/RedBook/wrap.rb +5 -5
- data/examples/misc/OGLBench.rb +337 -0
- data/examples/misc/anisotropic.rb +1 -1
- data/examples/misc/fbo_test.rb +356 -0
- data/examples/misc/font-glut.rb +1 -1
- data/examples/misc/glfwtest.rb +30 -0
- data/examples/misc/md2model.rb +15 -0
- data/examples/misc/plane.rb +1 -1
- data/examples/misc/readpixel.rb +1 -1
- data/examples/misc/sdltest.rb +34 -0
- data/examples/misc/trislam.rb +828 -0
- data/ext/common/common.h +126 -218
- data/ext/common/conv.h +244 -0
- data/ext/common/funcdef.h +280 -0
- data/ext/common/gl-error.h +23 -0
- data/ext/common/gl-types.h +14 -0
- data/ext/gl/gl-1.0-1.1.c +497 -1255
- data/ext/gl/gl-1.2.c +121 -304
- data/ext/gl/gl-1.3.c +78 -339
- data/ext/gl/gl-1.4.c +102 -164
- data/ext/gl/gl-1.5.c +42 -173
- data/ext/gl/gl-2.0.c +273 -1039
- data/ext/gl/gl-2.1.c +15 -19
- data/ext/gl/gl-enums.c +3 -2
- data/ext/gl/gl-error.c +104 -0
- data/ext/gl/gl-ext-3dfx.c +27 -0
- data/ext/gl/gl-ext-arb.c +812 -12
- data/ext/gl/gl-ext-ati.c +41 -0
- data/ext/gl/gl-ext-ext.c +791 -119
- data/ext/gl/gl-ext-gremedy.c +41 -0
- data/ext/gl/gl-ext-nv.c +679 -0
- data/ext/gl/gl.c +48 -28
- data/ext/gl/mkrf_conf.rb +13 -10
- data/ext/glu/glu-enums.c +3 -2
- data/ext/glu/glu.c +136 -41
- data/ext/glu/mkrf_conf.rb +15 -12
- data/ext/glut/glut.c +37 -80
- data/ext/glut/mkrf_conf.rb +17 -13
- data/lib/opengl.rb +29 -53
- data/test/tc_common.rb +9 -3
- data/test/tc_ext_arb.rb +397 -3
- data/test/tc_ext_ati.rb +33 -0
- data/test/tc_ext_ext.rb +479 -2
- data/test/tc_ext_gremedy.rb +36 -0
- data/test/tc_ext_nv.rb +357 -0
- data/test/tc_func_10_11.rb +93 -67
- data/test/tc_func_12.rb +11 -11
- data/test/tc_func_13.rb +38 -18
- data/test/tc_func_14.rb +2 -2
- data/test/tc_func_15.rb +10 -10
- data/test/tc_func_20.rb +20 -20
- data/test/tc_func_21.rb +53 -22
- data/test/tc_glu.rb +9 -4
- data/test/tc_misc.rb +15 -2
- metadata +22 -8
- data/doc/extensions.txt +0 -361
- data/examples/RedBook/aaindex.rb +0 -97
- data/examples/misc/smooth.rb +0 -42
- data/examples/misc/test.rb +0 -65
data/ext/glu/mkrf_conf.rb
CHANGED
|
@@ -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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
data/ext/glut/glut.c
CHANGED
|
@@ -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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
382
|
-
|
|
383
|
-
|
|
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
|
-
|
|
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
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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*)
|
|
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*)
|
|
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*)
|
|
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
|
-
|
|
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);
|
data/ext/glut/mkrf_conf.rb
CHANGED
|
@@ -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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
data/lib/opengl.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
50
|
-
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
data/test/tc_common.rb
CHANGED
|
@@ -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
|
-
|
|
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)
|
|
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
|
-
|
|
93
|
+
print "#{name} not supported, test skipped"
|
|
88
94
|
return false
|
|
89
95
|
end
|
|
90
96
|
end
|