ruby-opengl 0.33.0

Sign up to get free protection for your applications and to get access to all the features.
data/ext/glut/glut.c ADDED
@@ -0,0 +1,1776 @@
1
+ /*
2
+ * Last edit by previous maintainer:
3
+ * 2004/03/02 01:13:06, yoshi
4
+ *
5
+ * Copyright (C) 1999 - 2005 Yoshi <yoshi@giganet.net>
6
+ * Copyright (C) 2006 John M. Gabriele <jmg3000@gmail.com>
7
+ *
8
+ * This program is distributed under the terms of the MIT license.
9
+ * See the included COPYRIGHT file for the terms of this license.
10
+ *
11
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
13
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
14
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
15
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
16
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
17
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18
+ *
19
+ */
20
+
21
+ #ifdef __APPLE__
22
+ #include <OpenGL/gl.h>
23
+ #include <OpenGL/glu.h>
24
+ #include <GLUT/glut.h>
25
+ #elif defined WIN32
26
+ #include <windows.h>
27
+ #include <GL/gl.h>
28
+ #include <GL/glu.h>
29
+ #include <GL/glut.h>
30
+ #else
31
+ #include <GL/gl.h>
32
+ #include <GL/glu.h>
33
+ #include <GL/glut.h>
34
+ #endif
35
+
36
+ #include <ruby.h>
37
+
38
+ static int callId; /* 'call' method id */
39
+
40
+ /* callback define macro */
41
+ #define WINDOW_CALLBACK_SETUP(_funcname) \
42
+ static VALUE _funcname = Qnil; \
43
+ static void glut_ ## _funcname ## Callback(); \
44
+ static VALUE \
45
+ glut_ ## _funcname(obj,arg1) \
46
+ VALUE obj,arg1; \
47
+ { \
48
+ int win; \
49
+ if (!rb_obj_is_kind_of(arg1,rb_cProc) && !NIL_P(arg1)) \
50
+ rb_raise(rb_eTypeError, "Glut.%s:%s",#_funcname, rb_class2name(CLASS_OF(arg1))); \
51
+ win = glutGetWindow(); \
52
+ if (win == 0) \
53
+ rb_raise(rb_eRuntimeError, "Glut.%s needs current window", #_funcname); \
54
+ rb_ary_store(_funcname, win, arg1); \
55
+ glut ## _funcname(glut_ ## _funcname ## Callback); \
56
+ return Qnil; \
57
+ }
58
+
59
+ #define WINDOW_CALLBACK_DEFINE(_funcname) \
60
+ rb_define_module_function(module, "glut" # _funcname, glut_ ## _funcname , 1); \
61
+ rb_global_variable(&_funcname); \
62
+ _funcname = rb_ary_new()
63
+
64
+
65
+ /*
66
+ * GLUT Implementation
67
+ */
68
+
69
+ /* GLUT initialization sub-API. */
70
+ static VALUE g_arg_array;
71
+
72
+ static VALUE glut_Init( int argc, VALUE * argv, VALUE obj)
73
+ {
74
+ #if 0
75
+ int argcp = 1;
76
+ if (TYPE(arg1) != T_STRING)
77
+ rb_raise(rb_eTypeError, "Glut.Init:%s", rb_class2name(CLASS_OF(arg1)));
78
+ glutInit(&argcp, (char**)&(RSTRING(arg1)->ptr));
79
+ #endif
80
+ int largc;
81
+ char** largv;
82
+ int i, j;
83
+ int find;
84
+ VALUE new_argv;
85
+ VALUE arg1;
86
+ VALUE ptr;
87
+ if (rb_scan_args(argc, argv, "01", &arg1) == 0)
88
+ {
89
+ arg1 = rb_eval_string("ARGV");
90
+ }
91
+ Check_Type(arg1, T_ARRAY);
92
+ largc = RARRAY(arg1)->len+1;
93
+ largv = ALLOCA_N(char*, largc+2);
94
+ largv[0] = STR2CSTR(rb_eval_string("$0"));
95
+ for (i = 1; i < largc; i++)
96
+ {
97
+ largv[i] = STR2CSTR(RARRAY(arg1)->ptr[i-1]);
98
+ }
99
+ largv[i] = NULL;
100
+ glutInit(&largc, largv);
101
+ new_argv = rb_ary_new2(largc-1);
102
+ g_arg_array = rb_ary_new();
103
+ for (i = 0; i < RARRAY(arg1)->len; i++) {
104
+ ptr = RARRAY(arg1)->ptr[i];
105
+ find = 0;
106
+ for (j = 1; largv[j]; j++)
107
+ {
108
+ if (STR2CSTR(ptr) == largv[j])
109
+ {
110
+ rb_ary_push(new_argv, ptr);
111
+ find = 1;
112
+ break;
113
+ }
114
+ }
115
+ if (!find)
116
+ {
117
+ rb_ary_push(g_arg_array, ptr);
118
+ }
119
+ }
120
+ return new_argv;
121
+ }
122
+
123
+
124
+ static VALUE glut_InitDisplayMode(obj,arg1)
125
+ VALUE obj,arg1;
126
+ {
127
+ unsigned int mode;
128
+ mode = (unsigned int)NUM2INT(arg1);
129
+ glutInitDisplayMode(mode);
130
+ return Qnil;
131
+ }
132
+
133
+
134
+ #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
135
+ static VALUE
136
+ glut_InitDisplayString(obj,arg1)
137
+ VALUE obj,arg1;
138
+ {
139
+ if (TYPE(arg1) != T_STRING)
140
+ rb_raise(rb_eTypeError, "Glut.InitDisplay:%s",rb_class2name(CLASS_OF(arg1)));
141
+ glutInitDisplayString(RSTRING(arg1)->ptr);
142
+ return Qnil;
143
+ }
144
+ #endif
145
+
146
+
147
+ static VALUE
148
+ glut_InitWindowPosition(obj,arg1,arg2)
149
+ VALUE obj,arg1,arg2;
150
+ {
151
+ int x,y;
152
+ x = NUM2INT(arg1);
153
+ y = NUM2INT(arg2);
154
+ glutInitWindowPosition(x,y);
155
+ return Qnil;
156
+ }
157
+
158
+
159
+ static VALUE
160
+ glut_InitWindowSize(obj, arg1, arg2)
161
+ VALUE obj,arg1,arg2;
162
+ {
163
+ int width,height;
164
+ width = NUM2INT(arg1);
165
+ height = NUM2INT(arg2);
166
+ glutInitWindowSize(width,height);
167
+ return Qnil;
168
+ }
169
+
170
+
171
+ static VALUE
172
+ glut_MainLoop(obj)
173
+ VALUE obj;
174
+ {
175
+ glutMainLoop();
176
+ return Qnil;
177
+ }
178
+
179
+ /* Added by James to reflect MacOSX's CheckLoop. */
180
+ static VALUE
181
+ glut_CheckLoop(obj)
182
+ VALUE obj;
183
+ {
184
+ glutMainLoop();
185
+ return Qnil;
186
+ }
187
+
188
+
189
+ WINDOW_CALLBACK_SETUP(DisplayFunc);
190
+ WINDOW_CALLBACK_SETUP(ReshapeFunc);
191
+ WINDOW_CALLBACK_SETUP(KeyboardFunc);
192
+ WINDOW_CALLBACK_SETUP(MouseFunc);
193
+ WINDOW_CALLBACK_SETUP(MotionFunc);
194
+ WINDOW_CALLBACK_SETUP(PassiveMotionFunc);
195
+ WINDOW_CALLBACK_SETUP(EntryFunc);
196
+ WINDOW_CALLBACK_SETUP(VisibilityFunc);
197
+ /*
198
+ CALLBACK_DEFINE(IdleFunc);
199
+ CALLBACK_DEFINE(TimerFunc);
200
+ MENU_CALLBACK_DEFINE(MenuStateFunc);
201
+ */
202
+ WINDOW_CALLBACK_SETUP(SpecialFunc);
203
+ WINDOW_CALLBACK_SETUP(SpaceballMotionFunc);
204
+ WINDOW_CALLBACK_SETUP(SpaceballRotateFunc);
205
+ WINDOW_CALLBACK_SETUP(SpaceballButtonFunc);
206
+ WINDOW_CALLBACK_SETUP(ButtonBoxFunc);
207
+ WINDOW_CALLBACK_SETUP(DialsFunc);
208
+ WINDOW_CALLBACK_SETUP(TabletMotionFunc);
209
+ WINDOW_CALLBACK_SETUP(TabletButtonFunc);
210
+ /*
211
+ MENU_CALLBACK_DEFINE(MenuStatusFunc);
212
+ */
213
+ WINDOW_CALLBACK_SETUP(OverlayDisplayFunc);
214
+ WINDOW_CALLBACK_SETUP(WindowStatusFunc);
215
+
216
+
217
+ /* GLUT window sub-API. */
218
+ static VALUE glut_CreateWindow(argc, argv, obj)
219
+ int argc;
220
+ VALUE* argv;
221
+ VALUE obj;
222
+ {
223
+ int ret;
224
+ VALUE title;
225
+ rb_scan_args(argc, argv, "01", &title);
226
+ if (argc == 0)
227
+ title = rb_eval_string("$0");
228
+ if (TYPE(title) != T_STRING)
229
+ rb_raise(rb_eTypeError, "Glut.CreateWindow:%s", rb_class2name(CLASS_OF(title)));
230
+ ret = glutCreateWindow(RSTRING(title)->ptr);
231
+
232
+ /* setup callback */
233
+ /*
234
+ glutDisplayFunc(glut_DisplayFuncCallback);
235
+ glutReshapeFunc(glut_ReshapeFuncCallback);
236
+ glutKeyboardFunc(glut_KeyboardFuncCallback);
237
+ glutMouseFunc(glut_MouseFuncCallback);
238
+ glutMotionFunc(glut_MotionFuncCallback);
239
+ glutPassiveMotionFunc(glut_PassiveMotionFuncCallback);
240
+ glutEntryFunc(glut_EntryFuncCallback);
241
+ glutVisibilityFunc(glut_VisibilityFuncCallback);
242
+ glutSpecialFunc(glut_SpecialFuncCallback);
243
+ glutSpaceballMotionFunc(glut_SpaceballMotionFuncCallback);
244
+ glutSpaceballRotateFunc(glut_SpaceballRotateFuncCallback);
245
+ glutSpaceballButtonFunc(glut_SpaceballButtonFuncCallback);
246
+ glutButtonBoxFunc(glut_ButtonBoxFuncCallback);
247
+ glutDialsFunc(glut_DialsFuncCallback);
248
+ glutTabletMotionFunc(glut_TabletMotionFuncCallback);
249
+ glutTabletButtonFunc(glut_TabletButtonFuncCallback);
250
+ glutOverlayDisplayFunc(glut_OverlayDisplayFuncCallback);
251
+ glutWindowStatusFunc(glut_WindowStatusFuncCallback);
252
+ */
253
+ return INT2NUM(ret);
254
+ }
255
+
256
+
257
+ static VALUE
258
+ glut_CreateSubWindow(obj,arg1,arg2,arg3,arg4,arg5)
259
+ VALUE obj,arg1,arg2,arg3,arg4,arg5;
260
+ {
261
+ int win, x, y, width, height;
262
+ int ret;
263
+ win = NUM2INT(arg1);
264
+ x = NUM2INT(arg2);
265
+ y = NUM2INT(arg3);
266
+ width = NUM2INT(arg4);
267
+ height = NUM2INT(arg5);
268
+ ret = glutCreateSubWindow(win, x, y, width, height);
269
+ return INT2NUM(ret);
270
+ }
271
+
272
+ static VALUE
273
+ glut_DestroyWindow(obj,arg1)
274
+ VALUE obj,arg1;
275
+ {
276
+ int win;
277
+ win = NUM2INT(arg1);
278
+ glutDestroyWindow(win);
279
+ return Qnil;
280
+ }
281
+
282
+
283
+ static VALUE
284
+ glut_PostRedisplay(obj)
285
+ VALUE obj;
286
+ {
287
+ glutPostRedisplay();
288
+ return Qnil;
289
+ }
290
+
291
+
292
+ static VALUE
293
+ glut_SwapBuffers(obj)
294
+ VALUE obj;
295
+ {
296
+ glutSwapBuffers();
297
+ return Qnil;
298
+ }
299
+
300
+
301
+ static VALUE
302
+ glut_GetWindow(obj)
303
+ VALUE obj;
304
+ {
305
+ int ret;
306
+ ret = glutGetWindow();
307
+ return INT2NUM(ret);
308
+ }
309
+
310
+
311
+ static VALUE
312
+ glut_SetWindow(obj,arg1)
313
+ VALUE obj,arg1;
314
+ {
315
+ int win;
316
+ win = NUM2INT(arg1);
317
+ glutSetWindow(win);
318
+ return Qnil;
319
+ }
320
+
321
+
322
+ static VALUE
323
+ glut_SetWindowTitle(obj,arg1)
324
+ VALUE obj,arg1;
325
+ {
326
+ if (TYPE(arg1) != T_STRING)
327
+ rb_raise(rb_eTypeError, "Glut.SetWindowTitle:%s", rb_class2name(CLASS_OF(arg1)));
328
+ glutSetWindowTitle(RSTRING(arg1)->ptr);
329
+ return Qnil;
330
+ }
331
+
332
+
333
+ static VALUE
334
+ glut_SetIconTitle(obj, arg1)
335
+ VALUE obj,arg1;
336
+ {
337
+ if (TYPE(arg1) != T_STRING)
338
+ rb_raise(rb_eTypeError, "Glut.IconTitle:%s", rb_class2name(CLASS_OF(arg1)));
339
+ glutSetIconTitle(RSTRING(arg1)->ptr);
340
+ return Qnil;
341
+ }
342
+
343
+
344
+ static VALUE
345
+ glut_PositionWindow(obj,arg1,arg2)
346
+ VALUE obj,arg1,arg2;
347
+ {
348
+ int x,y;
349
+ x = NUM2INT(arg1);
350
+ y = NUM2INT(arg2);
351
+ glutPositionWindow(x,y);
352
+ return Qnil;
353
+ }
354
+
355
+
356
+ static VALUE
357
+ glut_ReshapeWindow(obj,arg1,arg2)
358
+ VALUE obj,arg1,arg2;
359
+ {
360
+ int width,height;
361
+ width = NUM2INT(arg1);
362
+ height = NUM2INT(arg2);
363
+ glutReshapeWindow(width, height);
364
+ return Qnil;
365
+ }
366
+
367
+
368
+ static VALUE
369
+ glut_PopWindow(obj)
370
+ VALUE obj;
371
+ {
372
+ glutPopWindow();
373
+ return Qnil;
374
+ }
375
+
376
+
377
+ static VALUE
378
+ glut_PushWidow(obj)
379
+ VALUE obj;
380
+ {
381
+ glutPushWindow();
382
+ return Qnil;
383
+ }
384
+
385
+
386
+ static VALUE
387
+ glut_IconifyWindow(obj)
388
+ VALUE obj;
389
+ {
390
+ glutIconifyWindow();
391
+ return Qnil;
392
+ }
393
+
394
+
395
+ static VALUE
396
+ glut_ShowWindow(obj)
397
+ VALUE obj;
398
+ {
399
+ glutShowWindow();
400
+ return Qnil;
401
+ }
402
+
403
+
404
+ static VALUE
405
+ glut_HideWindow(obj)
406
+ VALUE obj;
407
+ {
408
+ glutHideWindow();
409
+ return Qnil;
410
+ }
411
+
412
+
413
+ #if (GLUT_API_VERSION >= 3)
414
+ static VALUE
415
+ glut_FullScreen(obj)
416
+ VALUE obj;
417
+ {
418
+ glutFullScreen();
419
+ return Qnil;
420
+ }
421
+
422
+
423
+ static VALUE
424
+ glut_SetCursor(obj,arg1)
425
+ VALUE obj,arg1;
426
+ {
427
+ int cursor;
428
+ cursor = NUM2INT(arg1);
429
+ glutSetCursor(cursor);
430
+ return Qnil;
431
+ }
432
+
433
+
434
+ #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
435
+ static VALUE
436
+ glut_WarpPointer(obj,arg1,arg2)
437
+ VALUE obj,arg1,arg2;
438
+ {
439
+ int x,y;
440
+ x = NUM2INT(arg1);
441
+ y = NUM2INT(arg2);
442
+ glutWarpPointer(x,y);
443
+ return Qnil;
444
+ }
445
+ #endif
446
+
447
+
448
+ /* GLUT overlay sub-API. */
449
+ static VALUE
450
+ glut_EstablishOverlay(obj)
451
+ VALUE obj;
452
+ {
453
+ glutEstablishOverlay();
454
+ return Qnil;
455
+ }
456
+
457
+
458
+ static VALUE
459
+ glut_RemoveOverlay(obj)
460
+ VALUE obj;
461
+ {
462
+ glutRemoveOverlay();
463
+ return Qnil;
464
+ }
465
+
466
+
467
+ static VALUE
468
+ glut_UseLayer(obj,arg1)
469
+ {
470
+ GLenum layer;
471
+ layer = (GLenum)NUM2INT(arg1);
472
+ glutUseLayer(layer);
473
+ return Qnil;
474
+ }
475
+
476
+
477
+ static VALUE
478
+ glut_PostOverlayRedisplay(obj)
479
+ VALUE obj;
480
+ {
481
+ glutPostOverlayRedisplay();
482
+ return Qnil;
483
+ }
484
+
485
+
486
+ static VALUE
487
+ glut_ShowOverlay(obj)
488
+ VALUE obj;
489
+ {
490
+ glutShowOverlay();
491
+ return Qnil;
492
+ }
493
+
494
+
495
+ static VALUE
496
+ glut_HideOverlay(obj)
497
+ VALUE obj;
498
+ {
499
+ glutHideOverlay();
500
+ return Qnil;
501
+ }
502
+ #endif
503
+
504
+
505
+ /* GLUT menu sub-API. */
506
+ static VALUE g_menucallback = Qnil;
507
+ static VALUE g_menuargs = Qnil;
508
+ static void
509
+ glut_CreateMenuCallback(value)
510
+ int value;
511
+ {
512
+ VALUE arg_pair;
513
+ VALUE func;
514
+ arg_pair = (VALUE)value;
515
+ func = rb_hash_aref(g_menucallback, rb_ary_entry(arg_pair, 0));
516
+ rb_funcall(func, callId, 1, rb_ary_entry(arg_pair, 1));
517
+ }
518
+
519
+
520
+ static VALUE
521
+ glut_CreateMenu(obj,arg1)
522
+ VALUE obj,arg1;
523
+ {
524
+ int menu;
525
+ VALUE ret;
526
+ if (!rb_obj_is_kind_of(arg1,rb_cProc) && !NIL_P(arg1))
527
+ rb_raise(rb_eTypeError, "Glut.CreateMenu:%s", rb_class2name(CLASS_OF(arg1)));
528
+ menu = glutCreateMenu(glut_CreateMenuCallback);
529
+ ret = INT2FIX(menu);
530
+ rb_hash_aset(g_menucallback, ret, arg1);
531
+ rb_hash_aset(g_menuargs, ret, rb_ary_new());
532
+ return ret;
533
+ }
534
+
535
+
536
+ static VALUE
537
+ glut_DestroyMenu(obj,arg1)
538
+ VALUE obj,arg1;
539
+ {
540
+ int menu;
541
+ menu = INT2FIX(arg1);
542
+ glutDestroyMenu(menu);
543
+ rb_hash_aset(g_menucallback, menu, Qnil);
544
+ rb_hash_aset(g_menuargs, menu, Qnil);
545
+ return Qnil;
546
+ }
547
+
548
+
549
+ static VALUE
550
+ glut_GetMenu(obj)
551
+ VALUE obj;
552
+ {
553
+ int ret;
554
+ ret = glutGetMenu();
555
+ return INT2NUM(ret);
556
+ }
557
+
558
+
559
+ static VALUE
560
+ glut_SetMenu(obj,arg1)
561
+ VALUE obj,arg1;
562
+ {
563
+ int menu;
564
+ menu = NUM2INT(arg1);
565
+ glutSetMenu(menu);
566
+ return Qnil;
567
+ }
568
+
569
+
570
+ static VALUE
571
+ glut_AddMenuEntry(obj,arg1,arg2)
572
+ VALUE obj,arg1,arg2;
573
+ {
574
+ int value;
575
+ int curmenuid;
576
+ VALUE arg_ary;
577
+ VALUE arg_pair;
578
+ if (TYPE(arg1) != T_STRING)
579
+ rb_raise(rb_eTypeError, "Glut.AddMenuEntry:%s", rb_class2name(CLASS_OF(arg1)));
580
+ curmenuid = glutGetMenu();
581
+ if (curmenuid == 0)
582
+ rb_raise(rb_eRuntimeError, "Glut.AddMenuEntry needs current menu");
583
+ arg_ary = rb_hash_aref(g_menuargs, INT2FIX(curmenuid));
584
+ arg_pair = rb_ary_new2(2);
585
+ rb_ary_store(arg_pair, 0, INT2FIX(curmenuid));
586
+ rb_ary_store(arg_pair, 1, arg2);
587
+ rb_ary_push(arg_ary, arg_pair);
588
+ glutAddMenuEntry(RSTRING(arg1)->ptr, arg_pair);
589
+ return Qnil;
590
+ }
591
+
592
+
593
+ static VALUE
594
+ glut_AddSubMenu(obj,arg1,arg2)
595
+ VALUE obj,arg1,arg2;
596
+ {
597
+ int value;
598
+ if (TYPE(arg1) != T_STRING)
599
+ rb_raise(rb_eTypeError, "Glut.AddSubMenu:%s", rb_class2name(CLASS_OF(arg1)));
600
+ value = NUM2INT(arg2);
601
+ glutAddSubMenu(RSTRING(arg1)->ptr, value);
602
+ return Qnil;
603
+ }
604
+
605
+
606
+ static VALUE glut_ChangeToMenuEntry(obj,arg1,arg2,arg3)
607
+ VALUE obj,arg1,arg2,arg3;
608
+ {
609
+ VALUE arg_ary;
610
+ VALUE arg_pair;
611
+ int item,value;
612
+ int curmenuid;
613
+ item = NUM2INT(arg1);
614
+ if (TYPE(arg2) != T_STRING)
615
+ rb_raise(rb_eTypeError, "Glut.ChangeToMenuEntry:%s", rb_class2name(CLASS_OF(arg1)));
616
+ curmenuid = glutGetMenu();
617
+ if (curmenuid == 0)
618
+ rb_raise(rb_eRuntimeError, "Glut.ChangeToMenuEntry needs current menu");
619
+ arg_ary = rb_hash_aref(g_menuargs, INT2FIX(curmenuid));
620
+ arg_pair = rb_ary_new2(2);
621
+ rb_ary_store(arg_pair, 0, INT2FIX(curmenuid));
622
+ rb_ary_store(arg_pair, 1, arg2);
623
+ rb_ary_store(arg_ary, item, arg_pair);
624
+ glutChangeToMenuEntry(item, RSTRING(arg2)->ptr, arg_pair);
625
+ return Qnil;
626
+ }
627
+
628
+
629
+ static VALUE glut_ChangeToSubMenu(obj,arg1,arg2,arg3)
630
+ VALUE obj,arg1,arg2,arg3;
631
+ {
632
+ int item,submenu;
633
+ item = NUM2INT(arg1);
634
+ submenu = NUM2INT(arg3);
635
+ if (TYPE(arg2) != T_STRING)
636
+ rb_raise(rb_eTypeError, "Glut.ChangeToSubMenu:%s",
637
+ rb_class2name(CLASS_OF(arg1)));
638
+ glutChangeToSubMenu(item, RSTRING(arg2)->ptr, submenu);
639
+ return Qnil;
640
+ }
641
+
642
+
643
+ static VALUE glut_RemoveMenuItem( VALUE obj, VALUE arg1 )
644
+ {
645
+ int item;
646
+ int curmenuid;
647
+ VALUE arg_ary;
648
+ item = NUM2INT(arg1);
649
+ glutRemoveMenuItem(item);
650
+ curmenuid = glutGetMenu();
651
+ if (curmenuid == 0)
652
+ rb_raise(rb_eRuntimeError, "Glut.RemoveMenuItem needs current menu");
653
+ arg_ary = rb_hash_aref(g_menuargs, INT2FIX(curmenuid));
654
+ rb_ary_delete(arg_ary, item);
655
+ return Qnil;
656
+ }
657
+
658
+
659
+ static VALUE
660
+ glut_AttachMenu(obj,arg1)
661
+ VALUE obj, arg1;
662
+ {
663
+ int button;
664
+ button = NUM2INT(arg1);
665
+ glutAttachMenu(button);
666
+ return Qnil;
667
+ }
668
+
669
+
670
+ static VALUE
671
+ glut_DetachMenu(obj,arg1)
672
+ VALUE obj, arg1;
673
+ {
674
+ int button;
675
+ button = NUM2INT(arg1);
676
+ glutDetachMenu(button);
677
+ return Qnil;
678
+ }
679
+
680
+
681
+ /* GLUT sub-API. */
682
+ static void glut_DisplayFuncCallback(void)
683
+ {
684
+ VALUE func;
685
+ func = rb_ary_entry(DisplayFunc, glutGetWindow());
686
+ if (!NIL_P(func))
687
+ rb_funcall(func, callId, 0);
688
+ }
689
+
690
+
691
+ static void
692
+ glut_ReshapeFuncCallback(width, height)
693
+ int width, height;
694
+ {
695
+ VALUE func;
696
+ func = rb_ary_entry( ReshapeFunc, glutGetWindow());
697
+ if (!NIL_P(func))
698
+ rb_funcall(func, callId, 2, INT2FIX(width), INT2FIX(height));
699
+ }
700
+
701
+
702
+ static void
703
+ glut_KeyboardFuncCallback(key, x, y)
704
+ unsigned char key;
705
+ int x,y;
706
+ {
707
+ VALUE func;
708
+ func = rb_ary_entry(KeyboardFunc, glutGetWindow());
709
+ if (!NIL_P(func))
710
+ rb_funcall(func, callId, 3, INT2FIX(key), INT2FIX(x), INT2FIX(y));
711
+ }
712
+
713
+
714
+ static void
715
+ glut_MouseFuncCallback(button, state, x, y)
716
+ int button, state, x, y;
717
+ {
718
+ VALUE func;
719
+ func = rb_ary_entry(MouseFunc, glutGetWindow());
720
+ if (!NIL_P(func))
721
+ rb_funcall(func, callId, 4, INT2FIX(button), INT2FIX(state), INT2FIX(x), INT2FIX(y));
722
+ }
723
+
724
+
725
+ static void
726
+ glut_MotionFuncCallback(x, y)
727
+ int x, y;
728
+ {
729
+ VALUE func;
730
+ func = rb_ary_entry(MotionFunc, glutGetWindow());
731
+ if (!NIL_P(func))
732
+ rb_funcall(func, callId, 2,INT2FIX(x), INT2FIX(y));
733
+ }
734
+
735
+
736
+ static void
737
+ glut_PassiveMotionFuncCallback(x, y)
738
+ int x, y;
739
+ {
740
+ VALUE func;
741
+ func = rb_ary_entry(PassiveMotionFunc, glutGetWindow());
742
+ if (!NIL_P(func))
743
+ rb_funcall(func, callId, 2,INT2FIX(x), INT2FIX(y));
744
+ }
745
+
746
+
747
+ static void
748
+ glut_EntryFuncCallback(state)
749
+ int state;
750
+ {
751
+ VALUE func;
752
+ func = rb_ary_entry(EntryFunc,glutGetWindow());
753
+ if (!NIL_P(func))
754
+ rb_funcall(func, callId, 1, INT2NUM(state));
755
+ }
756
+
757
+
758
+ static void
759
+ glut_VisibilityFuncCallback(state)
760
+ int state;
761
+ {
762
+ VALUE func;
763
+ func = rb_ary_entry(VisibilityFunc, glutGetWindow());
764
+ if (!NIL_P(func))
765
+ rb_funcall(func, callId, 1, INT2NUM(state));
766
+ }
767
+
768
+
769
+ static VALUE idle_func = Qnil;
770
+ static void
771
+ glut_IdleFuncCallback()
772
+ {
773
+ if (!NIL_P(idle_func))
774
+ rb_funcall(idle_func, callId, 0);
775
+ }
776
+
777
+
778
+ static VALUE
779
+ glut_IdleFunc(obj, arg1)
780
+ VALUE obj,arg1;
781
+ {
782
+ if (!rb_obj_is_kind_of(arg1,rb_cProc) && !NIL_P(arg1))
783
+ rb_raise(rb_eTypeError, "glutIdleFunc:%s", rb_class2name(CLASS_OF(arg1)));
784
+ idle_func = arg1;
785
+ glutIdleFunc(glut_IdleFuncCallback);
786
+ return Qnil;
787
+ }
788
+
789
+
790
+ static VALUE timer_func = Qnil;
791
+ static void
792
+ glut_TimerFuncCallback(value)
793
+ int value;
794
+ {
795
+ if (!NIL_P(timer_func))
796
+ rb_funcall(timer_func, callId, 1, INT2NUM(value));
797
+ }
798
+
799
+
800
+ static VALUE
801
+ glut_TimerFunc(obj, arg1, arg2, arg3)
802
+ VALUE obj,arg1,arg2,arg3;
803
+ {
804
+ unsigned int millis;
805
+ int value;
806
+ millis = (unsigned int)NUM2INT(arg1);
807
+ value = NUM2INT(arg3);
808
+ if (!rb_obj_is_kind_of(arg2,rb_cProc))
809
+ rb_raise(rb_eTypeError, "glutTimerFunc:%s", rb_class2name(CLASS_OF(arg2)));
810
+ timer_func = arg2;
811
+ glutTimerFunc(millis, glut_TimerFuncCallback, value);
812
+ return Qnil;
813
+ }
814
+
815
+
816
+ static VALUE menustate_func = Qnil;
817
+ static void
818
+ glut_MenuStateFuncCallback(state)
819
+ int state;
820
+ {
821
+ if (!NIL_P(menustate_func))
822
+ rb_funcall(menustate_func, callId, 1, INT2NUM(state));
823
+ }
824
+
825
+
826
+ static VALUE
827
+ glut_MenuStateFunc(obj, arg1)
828
+ VALUE obj,arg1;
829
+ {
830
+ if (!rb_obj_is_kind_of(arg1,rb_cProc))
831
+ rb_raise(rb_eTypeError, "glutMenuStateFunc:%s",
832
+ rb_class2name(CLASS_OF(arg1)));
833
+ menustate_func = arg1;
834
+ glutMenuStateFunc(glut_MenuStateFuncCallback);
835
+ return Qnil;
836
+ }
837
+
838
+
839
+ #if (GLUT_API_VERSION >= 2)
840
+ static void
841
+ glut_SpecialFuncCallback(key, x, y)
842
+ int key, x, y;
843
+ {
844
+ VALUE func;
845
+ func = rb_ary_entry(SpecialFunc, glutGetWindow());
846
+ if (!NIL_P(func))
847
+ rb_funcall(func, callId, 3,INT2NUM(key), INT2FIX(x), INT2FIX(y));
848
+ }
849
+
850
+
851
+ static void
852
+ glut_SpaceballMotionFuncCallback(x, y, z)
853
+ int x,y,z;
854
+ {
855
+ VALUE func;
856
+ func = rb_ary_entry(SpaceballMotionFunc, glutGetWindow());
857
+ if (!NIL_P(func))
858
+ rb_funcall(func, callId, 3,INT2NUM(x), INT2FIX(y), INT2FIX(z));
859
+ }
860
+
861
+
862
+ static void
863
+ glut_SpaceballRotateFuncCallback(x, y, z)
864
+ int x,y,z;
865
+ {
866
+ VALUE func;
867
+ func = rb_ary_entry(SpaceballRotateFunc, glutGetWindow());
868
+ if (!NIL_P(func))
869
+ rb_funcall(func, callId, 3,INT2NUM(x), INT2FIX(y), INT2FIX(z));
870
+ }
871
+
872
+
873
+ static void
874
+ glut_SpaceballButtonFuncCallback(button, state)
875
+ int button, state;
876
+ {
877
+ VALUE func;
878
+ func = rb_ary_entry(SpaceballButtonFunc, glutGetWindow());
879
+ if (!NIL_P(func))
880
+ rb_funcall(func, callId, 2,INT2NUM(button), INT2NUM(state));
881
+ }
882
+
883
+
884
+ static void
885
+ glut_ButtonBoxFuncCallback(button, state)
886
+ int button, state;
887
+ {
888
+ VALUE func;
889
+ func = rb_ary_entry(ButtonBoxFunc, glutGetWindow());
890
+ if (!NIL_P(func))
891
+ rb_funcall(func, callId, 2,INT2NUM(button), INT2NUM(state));
892
+ }
893
+
894
+
895
+ static void
896
+ glut_DialsFuncCallback(dial, value)
897
+ int dial, value;
898
+ {
899
+ VALUE func;
900
+ func = rb_ary_entry(DialsFunc, glutGetWindow());
901
+ if (!NIL_P(func))
902
+ rb_funcall(func, callId, 2,INT2NUM(dial), INT2NUM(value));
903
+ }
904
+
905
+
906
+ static void
907
+ glut_TabletMotionFuncCallback(x, y)
908
+ int x, y;
909
+ {
910
+ VALUE func;
911
+ func = rb_ary_entry(TabletMotionFunc, glutGetWindow());
912
+ if (!NIL_P(func))
913
+ rb_funcall(func, callId, 2,INT2NUM(x), INT2NUM(y));
914
+ }
915
+
916
+
917
+ static void
918
+ glut_TabletButtonFuncCallback(button, state, x, y)
919
+ int button, state, x, y;
920
+ {
921
+ VALUE func;
922
+ func = rb_ary_entry(TabletButtonFunc, glutGetWindow());
923
+ if (!NIL_P(func))
924
+ rb_funcall(func, 4, INT2NUM(button), INT2NUM(state), INT2NUM(x), INT2NUM(y));
925
+ }
926
+
927
+
928
+ #if (GLUT_API_VERSION >= 3)
929
+ /*
930
+ extern void APIENTRY glutMenuStatusFunc(void (*)(int status, int x, int y));
931
+ */
932
+ static void
933
+ glut_OverlayDisplayFuncCallback()
934
+ {
935
+ VALUE func;
936
+ func = rb_ary_entry(OverlayDisplayFunc, glutGetWindow());
937
+ if (!NIL_P(func))
938
+ rb_funcall(func, callId, 0);
939
+ }
940
+
941
+
942
+ #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
943
+ static void
944
+ glut_WindowStatusFuncCallback(state)
945
+ int state;
946
+ {
947
+ VALUE func;
948
+ func = rb_ary_entry(OverlayDisplayFunc, glutGetWindow());
949
+ if (!NIL_P(func))
950
+ rb_funcall(func, callId, 1, INT2NUM(state));
951
+ }
952
+ #endif
953
+ #endif
954
+ #endif
955
+
956
+
957
+ /* GLUT color index sub-API. */
958
+ static VALUE
959
+ glut_SetColor(obj,arg1,arg2,arg3,arg4)
960
+ VALUE obj,arg1,arg2,arg3,arg4;
961
+ {
962
+ int set;
963
+ GLfloat red;
964
+ GLfloat green;
965
+ GLfloat blue;
966
+ set = NUM2INT(arg1);
967
+ red = (GLfloat)NUM2DBL(arg2);
968
+ green = (GLfloat)NUM2DBL(arg3);
969
+ blue = (GLfloat)NUM2DBL(arg4);
970
+ glutSetColor(set, red, green, blue);
971
+ return Qnil;
972
+ }
973
+
974
+
975
+ static VALUE
976
+ glut_GetColor(obj,arg1,arg2)
977
+ VALUE obj,arg1,arg2;
978
+ {
979
+ int ndx;
980
+ int component;
981
+ GLfloat ret;
982
+ ndx = NUM2INT(arg1);
983
+ component = NUM2INT(arg2);
984
+ ret = (GLfloat)glutGetColor(ndx, component);
985
+ return rb_float_new(ret);
986
+ }
987
+
988
+
989
+ static VALUE
990
+ glut_CopyColormap(obj,arg1)
991
+ VALUE obj,arg1;
992
+ {
993
+ int win;
994
+ win = NUM2INT(arg1);
995
+ glutCopyColormap(win);
996
+ return Qnil;
997
+ }
998
+
999
+
1000
+ /* GLUT state retrieval sub-API. */
1001
+ static VALUE
1002
+ glut_Get(obj,arg1)
1003
+ VALUE obj,arg1;
1004
+ {
1005
+ GLenum type;
1006
+ int ret;
1007
+ type = (GLenum)NUM2INT(arg1);
1008
+ ret = glutGet(type);
1009
+ return INT2NUM(ret);
1010
+ }
1011
+
1012
+
1013
+ static VALUE
1014
+ glut_DeviceGet(obj,arg1)
1015
+ VALUE obj,arg1;
1016
+ {
1017
+ GLenum type;
1018
+ int ret;
1019
+ type = (GLenum)NUM2INT(arg1);
1020
+ ret = glutDeviceGet(type);
1021
+ return INT2NUM(ret);
1022
+ }
1023
+
1024
+
1025
+ #if (GLUT_API_VERSION >= 2)
1026
+ /* GLUT extension support sub-API */
1027
+ static VALUE
1028
+ glut_ExtensionSupported(obj,arg1)
1029
+ VALUE obj,arg1;
1030
+ {
1031
+ int ret;
1032
+ if (TYPE(arg1) != T_STRING)
1033
+ rb_raise(rb_eTypeError, "glutExtensionSupported:%s",
1034
+ rb_class2name(CLASS_OF(arg1)));
1035
+ ret = glutExtensionSupported(RSTRING(arg1)->ptr);
1036
+ return INT2NUM(ret);
1037
+ }
1038
+ #endif
1039
+
1040
+
1041
+ #if (GLUT_API_VERSION >= 3)
1042
+ static VALUE
1043
+ glut_GetModifiers(obj)
1044
+ VALUE obj;
1045
+ {
1046
+ int ret;
1047
+ ret = glutGetModifiers();
1048
+ return INT2NUM(ret);
1049
+ }
1050
+
1051
+
1052
+ static VALUE
1053
+ glut_LayerGet(obj,arg1)
1054
+ VALUE obj,arg1;
1055
+ {
1056
+ GLenum type;
1057
+ int ret;
1058
+ type = (GLenum)NUM2INT(arg1);
1059
+ ret = glutLayerGet(type);
1060
+ return INT2NUM(ret);
1061
+ }
1062
+ #endif
1063
+
1064
+
1065
+
1066
+ /* GLUT font sub-API */
1067
+ static VALUE
1068
+ glut_BitmapCharacter(obj,arg1,arg2)
1069
+ VALUE obj,arg1,arg2;
1070
+ {
1071
+ int font;
1072
+ int character;
1073
+ font = NUM2INT(arg1);
1074
+ character = NUM2INT(arg2);
1075
+ glutBitmapCharacter((void*)font, character);
1076
+ return Qnil;
1077
+ }
1078
+
1079
+ /* Added by James since the normal function is messed up. His comment:
1080
+ * > BitmapCharacterX is my own ugly, lazy hack to avoid bus errors when
1081
+ * > trying to display text via GLUT. What really needs to happen is for
1082
+ * > someone more experienced with Ruby extensions to figure out why we
1083
+ * > can't pass the font values as arguments to this function without it
1084
+ * > falling over!
1085
+ */
1086
+ static VALUE
1087
+ glut_BitmapCharacterX(obj,arg2)
1088
+ VALUE obj,arg2;
1089
+ {
1090
+ int font;
1091
+ int character;
1092
+ /* font = NUM2INT(arg1); */
1093
+ character = NUM2INT(arg2);
1094
+ glutBitmapCharacter(GLUT_BITMAP_8_BY_13, character);
1095
+ return Qnil;
1096
+ }
1097
+
1098
+
1099
+ static VALUE
1100
+ glut_BitmapWidth(obj,arg1,arg2)
1101
+ VALUE obj,arg1,arg2;
1102
+ {
1103
+ int font;
1104
+ int character;
1105
+ int ret;
1106
+ font = NUM2INT(arg1);
1107
+ character = NUM2INT(arg2);
1108
+ ret = glutBitmapWidth((void*)font, character);
1109
+ return INT2NUM(ret);
1110
+ }
1111
+
1112
+
1113
+ static VALUE
1114
+ glut_StrokeCharacter(obj,arg1,arg2)
1115
+ VALUE obj,arg1,arg2;
1116
+ {
1117
+ int font;
1118
+ int character;
1119
+ font = NUM2INT(arg1);
1120
+ character = NUM2INT(arg2);
1121
+ glutStrokeCharacter((void*)font, character);
1122
+ return Qnil;
1123
+ }
1124
+
1125
+
1126
+ static VALUE
1127
+ glut_StrokeWidth(obj,arg1,arg2)
1128
+ VALUE obj,arg1,arg2;
1129
+ {
1130
+ int font;
1131
+ int character;
1132
+ int ret;
1133
+ font = NUM2INT(arg1);
1134
+ character = NUM2INT(arg2);
1135
+ ret = glutStrokeWidth((void*)font, character);
1136
+ return INT2NUM(ret);
1137
+ }
1138
+
1139
+
1140
+ #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
1141
+ static VALUE
1142
+ glut_BitmapLength(obj,arg1,arg2)
1143
+ VALUE obj,arg1,arg2;
1144
+ {
1145
+ int font;
1146
+ int ret;
1147
+ if (TYPE(arg2) != T_STRING) rb_raise(rb_eTypeError, "glutBitmapLength:%s",
1148
+ rb_class2name(CLASS_OF(arg2)));
1149
+ font = NUM2INT(arg1);
1150
+ ret = glutBitmapLength((void *)font, (const unsigned char*)RSTRING(arg2)->ptr);
1151
+ return INT2NUM(ret);
1152
+ }
1153
+
1154
+
1155
+ static VALUE
1156
+ glut_StrokeLength(obj,arg1,arg2)
1157
+ VALUE obj,arg1,arg2;
1158
+ {
1159
+ int font;
1160
+ int ret;
1161
+ if (TYPE(arg2) != T_STRING) rb_raise(rb_eTypeError, "glutStrokeLength:%s",
1162
+ rb_class2name(CLASS_OF(arg2)));
1163
+ font = NUM2INT(arg1);
1164
+ ret = glutStrokeLength((void *)font, (const unsigned char*)RSTRING(arg2)->ptr);
1165
+ return INT2NUM(ret);
1166
+ }
1167
+ #endif
1168
+
1169
+
1170
+ /* GLUT pre-built models sub-API */
1171
+ static VALUE
1172
+ glut_WireSphere(obj,arg1,arg2,arg3)
1173
+ VALUE obj,arg1,arg2,arg3;
1174
+ {
1175
+ GLdouble radius;
1176
+ GLint slices;
1177
+ GLint stacks;
1178
+ radius = (GLdouble)NUM2DBL(arg1);
1179
+ slices = (GLint)NUM2INT(arg2);
1180
+ stacks = (GLint)NUM2INT(arg3);
1181
+ glutWireSphere(radius, slices, stacks);
1182
+ return Qnil;
1183
+ }
1184
+
1185
+
1186
+ static VALUE
1187
+ glut_SolidSphere(obj,arg1,arg2,arg3)
1188
+ VALUE obj,arg1,arg2,arg3;
1189
+ {
1190
+ GLdouble radius;
1191
+ GLint slices;
1192
+ GLint stacks;
1193
+ radius = (GLdouble)NUM2DBL(arg1);
1194
+ slices = (GLint)NUM2INT(arg2);
1195
+ stacks = (GLint)NUM2INT(arg3);
1196
+ glutSolidSphere(radius, slices, stacks);
1197
+ return Qnil;
1198
+ }
1199
+
1200
+
1201
+ static VALUE
1202
+ glut_WireCone(obj,arg1,arg2,arg3,arg4)
1203
+ VALUE obj,arg1,arg2,arg3,arg4;
1204
+ {
1205
+ GLdouble base;
1206
+ GLdouble height;
1207
+ GLint slices;
1208
+ GLint stacks;
1209
+ base = (GLdouble)NUM2DBL(arg1);
1210
+ height = (GLdouble)NUM2DBL(arg2);
1211
+ slices = (GLint)NUM2INT(arg3);
1212
+ stacks = (GLint)NUM2INT(arg4);
1213
+ glutWireCone(base, height, slices, stacks);
1214
+ return Qnil;
1215
+ }
1216
+
1217
+
1218
+ static VALUE
1219
+ glut_SolidCone(obj,arg1,arg2,arg3,arg4)
1220
+ VALUE obj,arg1,arg2,arg3,arg4;
1221
+ {
1222
+ GLdouble base;
1223
+ GLdouble height;
1224
+ GLint slices;
1225
+ GLint stacks;
1226
+ base = (GLdouble)NUM2DBL(arg1);
1227
+ height = (GLdouble)NUM2DBL(arg2);
1228
+ slices = (GLint)NUM2INT(arg3);
1229
+ stacks = (GLint)NUM2INT(arg4);
1230
+ glutSolidCone(base, height, slices, stacks);
1231
+ return Qnil;
1232
+ }
1233
+
1234
+
1235
+ static VALUE
1236
+ glut_WireCube(obj,arg1)
1237
+ VALUE obj,arg1;
1238
+ {
1239
+ GLdouble size;
1240
+ size = (GLdouble)NUM2DBL(arg1);
1241
+ glutWireCube(size);
1242
+ return Qnil;
1243
+ }
1244
+
1245
+
1246
+ static VALUE
1247
+ glut_SolidCube(obj,arg1)
1248
+ VALUE obj,arg1;
1249
+ {
1250
+ GLdouble size;
1251
+ size = (GLdouble)NUM2DBL(arg1);
1252
+ glutSolidCube(size);
1253
+ return Qnil;
1254
+ }
1255
+
1256
+
1257
+ static VALUE
1258
+ glut_WireTorus(obj,arg1,arg2,arg3,arg4)
1259
+ VALUE obj,arg1,arg2,arg3,arg4;
1260
+ {
1261
+ GLdouble innerRadius;
1262
+ GLdouble outerRadius;
1263
+ GLint sides;
1264
+ GLint rings;
1265
+ innerRadius = (GLdouble)NUM2DBL(arg1);
1266
+ outerRadius = (GLdouble)NUM2DBL(arg2);
1267
+ sides = (GLint)NUM2INT(arg3);
1268
+ rings = (GLint)NUM2INT(arg4);
1269
+ glutWireTorus(innerRadius, outerRadius, sides, rings);
1270
+ return Qnil;
1271
+ }
1272
+
1273
+
1274
+ static VALUE
1275
+ glut_SolidTorus(obj,arg1,arg2,arg3,arg4)
1276
+ VALUE obj,arg1,arg2,arg3,arg4;
1277
+ {
1278
+ GLdouble innerRadius;
1279
+ GLdouble outerRadius;
1280
+ GLint sides;
1281
+ GLint rings;
1282
+ innerRadius = (GLdouble)NUM2DBL(arg1);
1283
+ outerRadius = (GLdouble)NUM2DBL(arg2);
1284
+ sides = (GLint)NUM2INT(arg3);
1285
+ rings = (GLint)NUM2INT(arg4);
1286
+ glutSolidTorus(innerRadius, outerRadius, sides, rings);
1287
+ return Qnil;
1288
+ }
1289
+
1290
+
1291
+ static VALUE
1292
+ glut_WireDodecahedron(obj)
1293
+ VALUE obj;
1294
+ {
1295
+ glutWireDodecahedron();
1296
+ return Qnil;
1297
+ }
1298
+
1299
+
1300
+ static VALUE
1301
+ glut_SolidDodecahedron(obj)
1302
+ VALUE obj;
1303
+ {
1304
+ glutSolidDodecahedron();
1305
+ return Qnil;
1306
+ }
1307
+
1308
+
1309
+ static VALUE
1310
+ glut_WireTeapot(obj,arg1)
1311
+ VALUE obj,arg1;
1312
+ {
1313
+ GLdouble size;
1314
+ size = (GLdouble)NUM2DBL(arg1);
1315
+ glutWireTeapot(size);
1316
+ return Qnil;
1317
+ }
1318
+
1319
+
1320
+ static VALUE
1321
+ glut_SolidTeapot(obj,arg1)
1322
+ VALUE obj,arg1;
1323
+ {
1324
+ GLdouble size;
1325
+ size = (GLdouble)NUM2DBL(arg1);
1326
+ glutSolidTeapot(size);
1327
+ return Qnil;
1328
+ }
1329
+
1330
+
1331
+ static VALUE
1332
+ glut_WireOctahedron(obj)
1333
+ VALUE obj;
1334
+ {
1335
+ glutWireOctahedron();
1336
+ return Qnil;
1337
+ }
1338
+
1339
+
1340
+ static VALUE
1341
+ glut_SolidOctahedron(obj)
1342
+ VALUE obj;
1343
+ {
1344
+ glutSolidOctahedron();
1345
+ return Qnil;
1346
+ }
1347
+
1348
+
1349
+ static VALUE
1350
+ glut_WireTetrahedron(obj)
1351
+ VALUE obj;
1352
+ {
1353
+ glutWireTetrahedron();
1354
+ return Qnil;
1355
+ }
1356
+
1357
+
1358
+ static VALUE
1359
+ glut_SolidTetrahedron(obj)
1360
+ VALUE obj;
1361
+ {
1362
+ glutSolidTetrahedron();
1363
+ return Qnil;
1364
+ }
1365
+
1366
+
1367
+ static VALUE
1368
+ glut_WireIcosahedron(obj)
1369
+ VALUE obj;
1370
+ {
1371
+ glutWireIcosahedron();
1372
+ return Qnil;
1373
+ }
1374
+
1375
+
1376
+ static VALUE
1377
+ glut_SolidIcosahedron(obj)
1378
+ VALUE obj;
1379
+ {
1380
+ glutSolidIcosahedron();
1381
+ return Qnil;
1382
+ }
1383
+
1384
+
1385
+ #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
1386
+ /* GLUT video resize sub-API. */
1387
+ static VALUE
1388
+ glut_VideoResizeGet(obj,arg1)
1389
+ VALUE obj,arg1;
1390
+ {
1391
+ GLenum param;
1392
+ int ret;
1393
+ param = (GLenum)NUM2INT(arg1);
1394
+ ret = glutVideoResizeGet(param);
1395
+ return INT2NUM(ret);
1396
+ }
1397
+
1398
+
1399
+ static VALUE
1400
+ glut_SetupVideoResizing(obj)
1401
+ VALUE obj;
1402
+ {
1403
+ glutSetupVideoResizing();
1404
+ return Qnil;
1405
+ }
1406
+
1407
+
1408
+ static VALUE
1409
+ glut_StopVideoResizing(obj)
1410
+ VALUE obj;
1411
+ {
1412
+ glutStopVideoResizing();
1413
+ return Qnil;
1414
+ }
1415
+
1416
+
1417
+ static VALUE
1418
+ glut_VideoResize(obj,arg1,arg2,arg3,arg4)
1419
+ VALUE obj,arg1,arg2,arg3,arg4;
1420
+ {
1421
+ int x;
1422
+ int y;
1423
+ int width;
1424
+ int height;
1425
+ x = NUM2INT(arg1);
1426
+ y = NUM2INT(arg2);
1427
+ width = NUM2INT(arg3);
1428
+ height = NUM2INT(arg4);
1429
+ glutVideoResize(x,y, width, height);
1430
+ return Qnil;
1431
+ }
1432
+
1433
+
1434
+ static VALUE
1435
+ glut_VideoPan(obj,arg1,arg2,arg3,arg4)
1436
+ VALUE obj,arg1,arg2,arg3,arg4;
1437
+ {
1438
+ int x;
1439
+ int y;
1440
+ int width;
1441
+ int height;
1442
+ x = NUM2INT(arg1);
1443
+ y = NUM2INT(arg2);
1444
+ width = NUM2INT(arg3);
1445
+ height = NUM2INT(arg4);
1446
+ glutVideoPan(x,y, width, height);
1447
+ return Qnil;
1448
+ }
1449
+
1450
+
1451
+ /* GLUT debugging sub-API. */
1452
+ static VALUE
1453
+ glut_ReportErrors(obj)
1454
+ VALUE obj;
1455
+ {
1456
+ glutReportErrors();
1457
+ return Qnil;
1458
+ }
1459
+ #endif
1460
+
1461
+
1462
+ /* Added by James. */
1463
+ static VALUE
1464
+ glut_GameModeString(obj,arg1)
1465
+ VALUE obj,arg1;
1466
+ {
1467
+ if (TYPE(arg1) != T_STRING)
1468
+ rb_raise(rb_eTypeError, "glutGameModeString:%s",
1469
+ rb_class2name(CLASS_OF(arg1)));
1470
+ glutGameModeString((const char*)RSTRING(arg1)->ptr);
1471
+ return Qnil;
1472
+ }
1473
+
1474
+
1475
+ static VALUE
1476
+ glut_EnterGameMode(obj)
1477
+ VALUE obj;
1478
+ {
1479
+ glutEnterGameMode();
1480
+ return Qnil;
1481
+ }
1482
+ /* end "Added by James." */
1483
+
1484
+
1485
+ static VALUE module;
1486
+
1487
+ void Init_glut()
1488
+ {
1489
+ module = rb_define_module("Glut");
1490
+
1491
+ rb_global_variable( &g_arg_array );
1492
+ rb_global_variable( &g_menucallback );
1493
+ rb_global_variable( &g_menuargs );
1494
+ g_menucallback = rb_hash_new();
1495
+ g_menuargs = rb_hash_new();
1496
+
1497
+ rb_define_module_function(module, "glutInit", glut_Init, -1);
1498
+ rb_define_module_function(module, "glutInitDisplayMode", glut_InitDisplayMode, 1);
1499
+ rb_define_module_function(module, "glutInitDisplayString", glut_InitDisplayString, 1);
1500
+ rb_define_module_function(module, "glutInitWindowPosition", glut_InitWindowPosition, 2);
1501
+ rb_define_module_function(module, "glutInitWindowSize", glut_InitWindowSize, 2);
1502
+ rb_define_module_function(module, "glutMainLoop", glut_MainLoop, 0);
1503
+
1504
+ /* Added by James. */
1505
+ rb_define_module_function(module, "glutCheckLoop", glut_CheckLoop, 0);
1506
+ rb_define_module_function(module, "glutGameModeString", glut_GameModeString, 1);
1507
+ rb_define_module_function(module, "glutEnterGameMode", glut_EnterGameMode, 0);
1508
+
1509
+ rb_define_module_function(module, "glutCreateWindow", glut_CreateWindow, -1);
1510
+ rb_define_module_function(module, "glutCreateSubWindow", glut_CreateSubWindow, 5);
1511
+ rb_define_module_function(module, "glutDestroyWindow", glut_DestroyWindow, 1);
1512
+ rb_define_module_function(module, "glutPostRedisplay", glut_PostRedisplay, 0);
1513
+ rb_define_module_function(module, "glutSwapBuffers", glut_SwapBuffers, 0);
1514
+ rb_define_module_function(module, "glutGetWindow", glut_GetWindow, 0);
1515
+ rb_define_module_function(module, "glutSetWindow", glut_SetWindow, 1);
1516
+ rb_define_module_function(module, "glutSetWindowTitle", glut_SetWindowTitle, 1);
1517
+ rb_define_module_function(module, "glutSetIconTitle", glut_SetIconTitle, 1);
1518
+ rb_define_module_function(module, "glutPositionWindow", glut_PositionWindow, 2);
1519
+ rb_define_module_function(module, "glutReshapeWindow", glut_ReshapeWindow, 2);
1520
+ rb_define_module_function(module, "glutPopWindow", glut_PopWindow, 0);
1521
+ rb_define_module_function(module, "glutPushWidow", glut_PushWidow, 0);
1522
+ rb_define_module_function(module, "glutIconifyWindow", glut_IconifyWindow, 0);
1523
+ rb_define_module_function(module, "glutShowWindow", glut_ShowWindow, 0);
1524
+ rb_define_module_function(module, "glutHideWindow", glut_HideWindow, 0);
1525
+ rb_define_module_function(module, "glutFullScreen", glut_FullScreen, 0);
1526
+ rb_define_module_function(module, "glutSetCursor", glut_SetCursor, 1);
1527
+ rb_define_module_function(module, "glutWarpPointer", glut_WarpPointer, 2);
1528
+ rb_define_module_function(module, "glutEstablishOverlay", glut_EstablishOverlay, 0);
1529
+ rb_define_module_function(module, "glutRemoveOverlay", glut_RemoveOverlay, 0);
1530
+ rb_define_module_function(module, "glutUseLayer", glut_UseLayer, 1);
1531
+ rb_define_module_function(module, "glutPostOverlayRedisplay", glut_PostOverlayRedisplay, 0);
1532
+ rb_define_module_function(module, "glutShowOverlay", glut_ShowOverlay, 0);
1533
+ rb_define_module_function(module, "glutHideOverlay", glut_HideOverlay, 0);
1534
+ rb_define_module_function(module, "glutCreateMenu", glut_CreateMenu, 1);
1535
+ rb_define_module_function(module, "glutDestroyMenu", glut_DestroyMenu, 1);
1536
+ rb_define_module_function(module, "glutGetMenu", glut_GetMenu, 0);
1537
+ rb_define_module_function(module, "glutSetMenu", glut_SetMenu, 1);
1538
+ rb_define_module_function(module, "glutAddMenuEntry", glut_AddMenuEntry, 2);
1539
+ rb_define_module_function(module, "glutAddSubMenu", glut_AddSubMenu, 2);
1540
+ rb_define_module_function(module, "glutChangeToMenuEntry", glut_ChangeToMenuEntry, 3);
1541
+ rb_define_module_function(module, "glutChangeToSubMenu", glut_ChangeToSubMenu, 3);
1542
+ rb_define_module_function(module, "glutRemoveMenuItem", glut_RemoveMenuItem, 1);
1543
+ rb_define_module_function(module, "glutAttachMenu", glut_AttachMenu, 1);
1544
+ rb_define_module_function(module, "glutDetachMenu", glut_DetachMenu, 1);
1545
+
1546
+ rb_define_module_function(module, "glutSetColor", glut_SetColor, 4);
1547
+ rb_define_module_function(module, "glutGetColor", glut_GetColor, 2);
1548
+ rb_define_module_function(module, "glutCopyColormap", glut_CopyColormap, 1);
1549
+ rb_define_module_function(module, "glutGet", glut_Get, 1);
1550
+ rb_define_module_function(module, "glutDeviceGet", glut_DeviceGet, 1);
1551
+ rb_define_module_function(module, "glutExtensionSupported", glut_ExtensionSupported, 1);
1552
+ rb_define_module_function(module, "glutGetModifiers", glut_GetModifiers, 0);
1553
+ rb_define_module_function(module, "glutLayerGet", glut_LayerGet, 1);
1554
+ rb_define_module_function(module, "glutBitmapCharacter", glut_BitmapCharacter, 2);
1555
+
1556
+ /* Added by James. */
1557
+ rb_define_module_function(module, "glutBitmapCharacterX", glut_BitmapCharacterX, 1);
1558
+
1559
+ rb_define_module_function(module, "glutBitmapWidth", glut_BitmapWidth, 2);
1560
+ rb_define_module_function(module, "glutStrokeCharacter", glut_StrokeCharacter, 2);
1561
+ rb_define_module_function(module, "glutStrokeWidth", glut_StrokeWidth, 2);
1562
+ rb_define_module_function(module, "glutBitmapLength", glut_BitmapLength, 2);
1563
+ rb_define_module_function(module, "glutStrokeLength", glut_StrokeLength, 2);
1564
+ rb_define_module_function(module, "glutWireSphere", glut_WireSphere, 3);
1565
+ rb_define_module_function(module, "glutSolidSphere", glut_SolidSphere, 3);
1566
+ rb_define_module_function(module, "glutWireCone", glut_WireCone, 4);
1567
+ rb_define_module_function(module, "glutSolidCone", glut_SolidCone, 4);
1568
+ rb_define_module_function(module, "glutWireCube", glut_WireCube, 1);
1569
+ rb_define_module_function(module, "glutSolidCube", glut_SolidCube, 1);
1570
+ rb_define_module_function(module, "glutWireTorus", glut_WireTorus, 4);
1571
+ rb_define_module_function(module, "glutSolidTorus", glut_SolidTorus, 4);
1572
+ rb_define_module_function(module, "glutWireDodecahedron", glut_WireDodecahedron, 0);
1573
+ rb_define_module_function(module, "glutSolidDodecahedron", glut_SolidDodecahedron, 0);
1574
+ rb_define_module_function(module, "glutWireTeapot", glut_WireTeapot, 1);
1575
+ rb_define_module_function(module, "glutSolidTeapot", glut_SolidTeapot, 1);
1576
+ rb_define_module_function(module, "glutWireOctahedron", glut_WireOctahedron, 0);
1577
+ rb_define_module_function(module, "glutSolidOctahedron", glut_SolidOctahedron, 0);
1578
+ rb_define_module_function(module, "glutWireTetrahedron", glut_WireTetrahedron, 0);
1579
+ rb_define_module_function(module, "glutSolidTetrahedron", glut_SolidTetrahedron, 0);
1580
+ rb_define_module_function(module, "glutWireIcosahedron", glut_WireIcosahedron, 0);
1581
+ rb_define_module_function(module, "glutSolidIcosahedron", glut_SolidIcosahedron, 0);
1582
+ rb_define_module_function(module, "glutVideoResizeGet", glut_VideoResizeGet, 1);
1583
+ rb_define_module_function(module, "glutSetupVideoResizing", glut_SetupVideoResizing, 0);
1584
+ rb_define_module_function(module, "glutStopVideoResizing", glut_StopVideoResizing, 0);
1585
+ rb_define_module_function(module, "glutVideoResize", glut_VideoResize, 4);
1586
+ rb_define_module_function(module, "glutVideoPan", glut_VideoPan, 4);
1587
+ rb_define_module_function(module, "glutReportErrors", glut_ReportErrors, 0);
1588
+ rb_define_module_function(module, "glutIdleFunc", glut_IdleFunc, 1);
1589
+ rb_define_module_function(module, "glutTimerFunc", glut_TimerFunc, 3);
1590
+
1591
+ rb_define_const(module, "GLUT_API_VERSION", INT2NUM(GLUT_API_VERSION));
1592
+ rb_define_const(module, "GLUT_XLIB_IMPLEMENTATION", INT2NUM(GLUT_XLIB_IMPLEMENTATION));
1593
+ rb_define_const(module, "GLUT_RGB", INT2NUM(GLUT_RGB));
1594
+ rb_define_const(module, "GLUT_RGBA", INT2NUM(GLUT_RGBA));
1595
+ rb_define_const(module, "GLUT_INDEX", INT2NUM(GLUT_INDEX));
1596
+ rb_define_const(module, "GLUT_SINGLE", INT2NUM(GLUT_SINGLE));
1597
+ rb_define_const(module, "GLUT_DOUBLE", INT2NUM(GLUT_DOUBLE));
1598
+ rb_define_const(module, "GLUT_ACCUM", INT2NUM(GLUT_ACCUM));
1599
+ rb_define_const(module, "GLUT_ALPHA", INT2NUM(GLUT_ALPHA));
1600
+ rb_define_const(module, "GLUT_DEPTH", INT2NUM(GLUT_DEPTH));
1601
+ rb_define_const(module, "GLUT_STENCIL", INT2NUM(GLUT_STENCIL));
1602
+ rb_define_const(module, "GLUT_MULTISAMPLE", INT2NUM(GLUT_MULTISAMPLE));
1603
+ rb_define_const(module, "GLUT_STEREO", INT2NUM(GLUT_STEREO));
1604
+ rb_define_const(module, "GLUT_LUMINANCE", INT2NUM(GLUT_LUMINANCE));
1605
+ rb_define_const(module, "GLUT_LEFT_BUTTON", INT2NUM(GLUT_LEFT_BUTTON));
1606
+ rb_define_const(module, "GLUT_MIDDLE_BUTTON", INT2NUM(GLUT_MIDDLE_BUTTON));
1607
+ rb_define_const(module, "GLUT_RIGHT_BUTTON", INT2NUM(GLUT_RIGHT_BUTTON));
1608
+ rb_define_const(module, "GLUT_DOWN", INT2NUM(GLUT_DOWN));
1609
+ rb_define_const(module, "GLUT_UP", INT2NUM(GLUT_UP));
1610
+ rb_define_const(module, "GLUT_KEY_F1", INT2NUM(GLUT_KEY_F1));
1611
+ rb_define_const(module, "GLUT_KEY_F2", INT2NUM(GLUT_KEY_F2));
1612
+ rb_define_const(module, "GLUT_KEY_F3", INT2NUM(GLUT_KEY_F3));
1613
+ rb_define_const(module, "GLUT_KEY_F4", INT2NUM(GLUT_KEY_F4));
1614
+ rb_define_const(module, "GLUT_KEY_F5", INT2NUM(GLUT_KEY_F5));
1615
+ rb_define_const(module, "GLUT_KEY_F6", INT2NUM(GLUT_KEY_F6));
1616
+ rb_define_const(module, "GLUT_KEY_F7", INT2NUM(GLUT_KEY_F7));
1617
+ rb_define_const(module, "GLUT_KEY_F8", INT2NUM(GLUT_KEY_F8));
1618
+ rb_define_const(module, "GLUT_KEY_F9", INT2NUM(GLUT_KEY_F9));
1619
+ rb_define_const(module, "GLUT_KEY_F10", INT2NUM(GLUT_KEY_F10));
1620
+ rb_define_const(module, "GLUT_KEY_F11", INT2NUM(GLUT_KEY_F11));
1621
+ rb_define_const(module, "GLUT_KEY_F12", INT2NUM(GLUT_KEY_F12));
1622
+ rb_define_const(module, "GLUT_KEY_LEFT", INT2NUM(GLUT_KEY_LEFT));
1623
+ rb_define_const(module, "GLUT_KEY_UP", INT2NUM(GLUT_KEY_UP));
1624
+ rb_define_const(module, "GLUT_KEY_RIGHT", INT2NUM(GLUT_KEY_RIGHT));
1625
+ rb_define_const(module, "GLUT_KEY_DOWN", INT2NUM(GLUT_KEY_DOWN));
1626
+ rb_define_const(module, "GLUT_KEY_PAGE_UP", INT2NUM(GLUT_KEY_PAGE_UP));
1627
+ rb_define_const(module, "GLUT_KEY_PAGE_DOWN", INT2NUM(GLUT_KEY_PAGE_DOWN));
1628
+ rb_define_const(module, "GLUT_KEY_HOME", INT2NUM(GLUT_KEY_HOME));
1629
+ rb_define_const(module, "GLUT_KEY_END", INT2NUM(GLUT_KEY_END));
1630
+ rb_define_const(module, "GLUT_KEY_INSERT", INT2NUM(GLUT_KEY_INSERT));
1631
+ rb_define_const(module, "GLUT_LEFT", INT2NUM(GLUT_LEFT));
1632
+ rb_define_const(module, "GLUT_ENTERED", INT2NUM(GLUT_ENTERED));
1633
+ rb_define_const(module, "GLUT_MENU_NOT_IN_USE", INT2NUM(GLUT_MENU_NOT_IN_USE));
1634
+ rb_define_const(module, "GLUT_MENU_IN_USE", INT2NUM(GLUT_MENU_IN_USE));
1635
+ rb_define_const(module, "GLUT_NOT_VISIBLE", INT2NUM(GLUT_NOT_VISIBLE));
1636
+ rb_define_const(module, "GLUT_VISIBLE", INT2NUM(GLUT_VISIBLE));
1637
+ rb_define_const(module, "GLUT_HIDDEN", INT2NUM(GLUT_HIDDEN));
1638
+ rb_define_const(module, "GLUT_FULLY_RETAINED", INT2NUM(GLUT_FULLY_RETAINED));
1639
+ rb_define_const(module, "GLUT_PARTIALLY_RETAINED", INT2NUM(GLUT_PARTIALLY_RETAINED));
1640
+ rb_define_const(module, "GLUT_FULLY_COVERED", INT2NUM(GLUT_FULLY_COVERED));
1641
+ rb_define_const(module, "GLUT_RED", INT2NUM(GLUT_RED));
1642
+ rb_define_const(module, "GLUT_GREEN", INT2NUM(GLUT_GREEN));
1643
+ rb_define_const(module, "GLUT_BLUE", INT2NUM(GLUT_BLUE));
1644
+ rb_define_const(module, "GLUT_WINDOW_X", INT2NUM(GLUT_WINDOW_X));
1645
+ rb_define_const(module, "GLUT_WINDOW_Y", INT2NUM(GLUT_WINDOW_Y));
1646
+ rb_define_const(module, "GLUT_WINDOW_WIDTH", INT2NUM(GLUT_WINDOW_WIDTH));
1647
+ rb_define_const(module, "GLUT_WINDOW_HEIGHT", INT2NUM(GLUT_WINDOW_HEIGHT));
1648
+ rb_define_const(module, "GLUT_WINDOW_BUFFER_SIZE", INT2NUM(GLUT_WINDOW_BUFFER_SIZE));
1649
+ rb_define_const(module, "GLUT_WINDOW_STENCIL_SIZE", INT2NUM(GLUT_WINDOW_STENCIL_SIZE));
1650
+ rb_define_const(module, "GLUT_WINDOW_DEPTH_SIZE", INT2NUM(GLUT_WINDOW_DEPTH_SIZE));
1651
+ rb_define_const(module, "GLUT_WINDOW_RED_SIZE", INT2NUM(GLUT_WINDOW_RED_SIZE));
1652
+ rb_define_const(module, "GLUT_WINDOW_GREEN_SIZE", INT2NUM(GLUT_WINDOW_GREEN_SIZE));
1653
+ rb_define_const(module, "GLUT_WINDOW_BLUE_SIZE", INT2NUM(GLUT_WINDOW_BLUE_SIZE));
1654
+ rb_define_const(module, "GLUT_WINDOW_ALPHA_SIZE", INT2NUM(GLUT_WINDOW_ALPHA_SIZE));
1655
+ rb_define_const(module, "GLUT_WINDOW_ACCUM_RED_SIZE", INT2NUM(GLUT_WINDOW_ACCUM_RED_SIZE));
1656
+ rb_define_const(module, "GLUT_WINDOW_ACCUM_GREEN_SIZE", INT2NUM(GLUT_WINDOW_ACCUM_GREEN_SIZE));
1657
+ rb_define_const(module, "GLUT_WINDOW_ACCUM_BLUE_SIZE", INT2NUM(GLUT_WINDOW_ACCUM_BLUE_SIZE));
1658
+ rb_define_const(module, "GLUT_WINDOW_ACCUM_ALPHA_SIZE", INT2NUM(GLUT_WINDOW_ACCUM_ALPHA_SIZE));
1659
+ rb_define_const(module, "GLUT_WINDOW_DOUBLEBUFFER", INT2NUM(GLUT_WINDOW_DOUBLEBUFFER));
1660
+ rb_define_const(module, "GLUT_WINDOW_RGBA", INT2NUM(GLUT_WINDOW_RGBA));
1661
+ rb_define_const(module, "GLUT_WINDOW_PARENT", INT2NUM(GLUT_WINDOW_PARENT));
1662
+ rb_define_const(module, "GLUT_WINDOW_NUM_CHILDREN", INT2NUM(GLUT_WINDOW_NUM_CHILDREN));
1663
+ rb_define_const(module, "GLUT_WINDOW_COLORMAP_SIZE", INT2NUM(GLUT_WINDOW_COLORMAP_SIZE));
1664
+ rb_define_const(module, "GLUT_WINDOW_NUM_SAMPLES", INT2NUM(GLUT_WINDOW_NUM_SAMPLES));
1665
+ rb_define_const(module, "GLUT_WINDOW_STEREO", INT2NUM(GLUT_WINDOW_STEREO));
1666
+ rb_define_const(module, "GLUT_WINDOW_CURSOR", INT2NUM(GLUT_WINDOW_CURSOR));
1667
+ rb_define_const(module, "GLUT_SCREEN_WIDTH", INT2NUM(GLUT_SCREEN_WIDTH));
1668
+ rb_define_const(module, "GLUT_SCREEN_HEIGHT", INT2NUM(GLUT_SCREEN_HEIGHT));
1669
+ rb_define_const(module, "GLUT_SCREEN_WIDTH_MM", INT2NUM(GLUT_SCREEN_WIDTH_MM));
1670
+ rb_define_const(module, "GLUT_SCREEN_HEIGHT_MM", INT2NUM(GLUT_SCREEN_HEIGHT_MM));
1671
+ rb_define_const(module, "GLUT_MENU_NUM_ITEMS", INT2NUM(GLUT_MENU_NUM_ITEMS));
1672
+ rb_define_const(module, "GLUT_DISPLAY_MODE_POSSIBLE", INT2NUM(GLUT_DISPLAY_MODE_POSSIBLE));
1673
+ rb_define_const(module, "GLUT_INIT_WINDOW_X", INT2NUM(GLUT_INIT_WINDOW_X));
1674
+ rb_define_const(module, "GLUT_INIT_WINDOW_Y", INT2NUM(GLUT_INIT_WINDOW_Y));
1675
+ rb_define_const(module, "GLUT_INIT_WINDOW_WIDTH", INT2NUM(GLUT_INIT_WINDOW_WIDTH));
1676
+ rb_define_const(module, "GLUT_INIT_WINDOW_HEIGHT", INT2NUM(GLUT_INIT_WINDOW_HEIGHT));
1677
+ rb_define_const(module, "GLUT_INIT_DISPLAY_MODE", INT2NUM(GLUT_INIT_DISPLAY_MODE));
1678
+ rb_define_const(module, "GLUT_ELAPSED_TIME", INT2NUM(GLUT_ELAPSED_TIME));
1679
+ rb_define_const(module, "GLUT_HAS_KEYBOARD", INT2NUM(GLUT_HAS_KEYBOARD));
1680
+ rb_define_const(module, "GLUT_HAS_MOUSE", INT2NUM(GLUT_HAS_MOUSE));
1681
+ rb_define_const(module, "GLUT_HAS_SPACEBALL", INT2NUM(GLUT_HAS_SPACEBALL));
1682
+ rb_define_const(module, "GLUT_HAS_DIAL_AND_BUTTON_BOX", INT2NUM(GLUT_HAS_DIAL_AND_BUTTON_BOX));
1683
+ rb_define_const(module, "GLUT_HAS_TABLET", INT2NUM(GLUT_HAS_TABLET));
1684
+ rb_define_const(module, "GLUT_NUM_MOUSE_BUTTONS", INT2NUM(GLUT_NUM_MOUSE_BUTTONS));
1685
+ rb_define_const(module, "GLUT_NUM_SPACEBALL_BUTTONS", INT2NUM(GLUT_NUM_SPACEBALL_BUTTONS));
1686
+ rb_define_const(module, "GLUT_NUM_BUTTON_BOX_BUTTONS", INT2NUM(GLUT_NUM_BUTTON_BOX_BUTTONS));
1687
+ rb_define_const(module, "GLUT_NUM_DIALS", INT2NUM(GLUT_NUM_DIALS));
1688
+ rb_define_const(module, "GLUT_NUM_TABLET_BUTTONS", INT2NUM(GLUT_NUM_TABLET_BUTTONS));
1689
+ rb_define_const(module, "GLUT_OVERLAY_POSSIBLE", INT2NUM(GLUT_OVERLAY_POSSIBLE));
1690
+ rb_define_const(module, "GLUT_LAYER_IN_USE", INT2NUM(GLUT_LAYER_IN_USE));
1691
+ rb_define_const(module, "GLUT_HAS_OVERLAY", INT2NUM(GLUT_HAS_OVERLAY));
1692
+ rb_define_const(module, "GLUT_TRANSPARENT_INDEX", INT2NUM(GLUT_TRANSPARENT_INDEX));
1693
+ rb_define_const(module, "GLUT_NORMAL_DAMAGED", INT2NUM(GLUT_NORMAL_DAMAGED));
1694
+ rb_define_const(module, "GLUT_OVERLAY_DAMAGED", INT2NUM(GLUT_OVERLAY_DAMAGED));
1695
+ rb_define_const(module, "GLUT_VIDEO_RESIZE_POSSIBLE", INT2NUM(GLUT_VIDEO_RESIZE_POSSIBLE));
1696
+ rb_define_const(module, "GLUT_VIDEO_RESIZE_IN_USE", INT2NUM(GLUT_VIDEO_RESIZE_IN_USE));
1697
+ rb_define_const(module, "GLUT_VIDEO_RESIZE_X_DELTA", INT2NUM(GLUT_VIDEO_RESIZE_X_DELTA));
1698
+ rb_define_const(module, "GLUT_VIDEO_RESIZE_Y_DELTA", INT2NUM(GLUT_VIDEO_RESIZE_Y_DELTA));
1699
+ rb_define_const(module, "GLUT_VIDEO_RESIZE_WIDTH_DELTA", INT2NUM(GLUT_VIDEO_RESIZE_WIDTH_DELTA));
1700
+ rb_define_const(module, "GLUT_VIDEO_RESIZE_HEIGHT_DELTA", INT2NUM(GLUT_VIDEO_RESIZE_HEIGHT_DELTA));
1701
+ rb_define_const(module, "GLUT_VIDEO_RESIZE_X", INT2NUM(GLUT_VIDEO_RESIZE_X));
1702
+ rb_define_const(module, "GLUT_VIDEO_RESIZE_Y", INT2NUM(GLUT_VIDEO_RESIZE_Y));
1703
+ rb_define_const(module, "GLUT_VIDEO_RESIZE_WIDTH", INT2NUM(GLUT_VIDEO_RESIZE_WIDTH));
1704
+ rb_define_const(module, "GLUT_VIDEO_RESIZE_HEIGHT", INT2NUM(GLUT_VIDEO_RESIZE_HEIGHT));
1705
+ rb_define_const(module, "GLUT_NORMAL", INT2NUM(GLUT_NORMAL));
1706
+ rb_define_const(module, "GLUT_OVERLAY", INT2NUM(GLUT_OVERLAY));
1707
+ rb_define_const(module, "GLUT_ACTIVE_SHIFT", INT2NUM(GLUT_ACTIVE_SHIFT));
1708
+ rb_define_const(module, "GLUT_ACTIVE_CTRL", INT2NUM(GLUT_ACTIVE_CTRL));
1709
+ rb_define_const(module, "GLUT_ACTIVE_ALT", INT2NUM(GLUT_ACTIVE_ALT));
1710
+ rb_define_const(module, "GLUT_CURSOR_RIGHT_ARROW", INT2NUM(GLUT_CURSOR_RIGHT_ARROW));
1711
+ rb_define_const(module, "GLUT_CURSOR_LEFT_ARROW", INT2NUM(GLUT_CURSOR_LEFT_ARROW));
1712
+ rb_define_const(module, "GLUT_CURSOR_INFO", INT2NUM(GLUT_CURSOR_INFO));
1713
+ rb_define_const(module, "GLUT_CURSOR_DESTROY", INT2NUM(GLUT_CURSOR_DESTROY));
1714
+ rb_define_const(module, "GLUT_CURSOR_HELP", INT2NUM(GLUT_CURSOR_HELP));
1715
+ rb_define_const(module, "GLUT_CURSOR_CYCLE", INT2NUM(GLUT_CURSOR_CYCLE));
1716
+ rb_define_const(module, "GLUT_CURSOR_SPRAY", INT2NUM(GLUT_CURSOR_SPRAY));
1717
+ rb_define_const(module, "GLUT_CURSOR_WAIT", INT2NUM(GLUT_CURSOR_WAIT));
1718
+ rb_define_const(module, "GLUT_CURSOR_TEXT", INT2NUM(GLUT_CURSOR_TEXT));
1719
+ rb_define_const(module, "GLUT_CURSOR_CROSSHAIR", INT2NUM(GLUT_CURSOR_CROSSHAIR));
1720
+ rb_define_const(module, "GLUT_CURSOR_UP_DOWN", INT2NUM(GLUT_CURSOR_UP_DOWN));
1721
+ rb_define_const(module, "GLUT_CURSOR_LEFT_RIGHT", INT2NUM(GLUT_CURSOR_LEFT_RIGHT));
1722
+ rb_define_const(module, "GLUT_CURSOR_TOP_SIDE", INT2NUM(GLUT_CURSOR_TOP_SIDE));
1723
+ rb_define_const(module, "GLUT_CURSOR_BOTTOM_SIDE", INT2NUM(GLUT_CURSOR_BOTTOM_SIDE));
1724
+ rb_define_const(module, "GLUT_CURSOR_LEFT_SIDE", INT2NUM(GLUT_CURSOR_LEFT_SIDE));
1725
+ rb_define_const(module, "GLUT_CURSOR_RIGHT_SIDE", INT2NUM(GLUT_CURSOR_RIGHT_SIDE));
1726
+ rb_define_const(module, "GLUT_CURSOR_TOP_LEFT_CORNER", INT2NUM(GLUT_CURSOR_TOP_LEFT_CORNER));
1727
+ rb_define_const(module, "GLUT_CURSOR_TOP_RIGHT_CORNER", INT2NUM(GLUT_CURSOR_TOP_RIGHT_CORNER));
1728
+ rb_define_const(module, "GLUT_CURSOR_BOTTOM_RIGHT_CORNER", INT2NUM(GLUT_CURSOR_BOTTOM_RIGHT_CORNER));
1729
+ rb_define_const(module, "GLUT_CURSOR_BOTTOM_LEFT_CORNER", INT2NUM(GLUT_CURSOR_BOTTOM_LEFT_CORNER));
1730
+ rb_define_const(module, "GLUT_CURSOR_INHERIT", INT2NUM(GLUT_CURSOR_INHERIT));
1731
+ rb_define_const(module, "GLUT_CURSOR_NONE", INT2NUM(GLUT_CURSOR_NONE));
1732
+ rb_define_const(module, "GLUT_CURSOR_FULL_CROSSHAIR", INT2NUM(GLUT_CURSOR_FULL_CROSSHAIR));
1733
+ rb_define_const(module, "GLUT_BITMAP_9_BY_15", INT2NUM((VALUE)GLUT_BITMAP_9_BY_15));
1734
+ rb_define_const(module, "GLUT_BITMAP_8_BY_13", INT2NUM((VALUE)GLUT_BITMAP_8_BY_13));
1735
+ rb_define_const(module, "GLUT_BITMAP_TIMES_ROMAN_10", INT2NUM((VALUE)GLUT_BITMAP_TIMES_ROMAN_10));
1736
+ rb_define_const(module, "GLUT_BITMAP_TIMES_ROMAN_24", INT2NUM((VALUE)GLUT_BITMAP_TIMES_ROMAN_24));
1737
+ rb_define_const(module, "GLUT_BITMAP_HELVETICA_10", INT2NUM((VALUE)GLUT_BITMAP_HELVETICA_10));
1738
+ rb_define_const(module, "GLUT_BITMAP_HELVETICA_12", INT2NUM((VALUE)GLUT_BITMAP_HELVETICA_12));
1739
+ rb_define_const(module, "GLUT_BITMAP_HELVETICA_18", INT2NUM((VALUE)GLUT_BITMAP_HELVETICA_18));
1740
+ rb_define_const(module, "GLUT_STROKE_ROMAN", INT2NUM((VALUE)GLUT_STROKE_ROMAN));
1741
+ rb_define_const(module, "GLUT_STROKE_MONO_ROMAN", INT2NUM((VALUE)GLUT_STROKE_MONO_ROMAN));
1742
+
1743
+ callId = rb_intern("call");
1744
+
1745
+ WINDOW_CALLBACK_DEFINE(DisplayFunc);
1746
+ WINDOW_CALLBACK_DEFINE(ReshapeFunc);
1747
+ WINDOW_CALLBACK_DEFINE(KeyboardFunc);
1748
+ WINDOW_CALLBACK_DEFINE(MouseFunc);
1749
+ WINDOW_CALLBACK_DEFINE(MotionFunc);
1750
+ WINDOW_CALLBACK_DEFINE(PassiveMotionFunc);
1751
+ WINDOW_CALLBACK_DEFINE(EntryFunc);
1752
+ WINDOW_CALLBACK_DEFINE(VisibilityFunc);
1753
+ /*
1754
+ GENERAL_CALLBACK_DEFINE(IdleFunc);
1755
+ GENERAL_CALLBACK_DEFINE(TimerFunc);
1756
+ MENU_CALLBACK_DEFINE(MenuStateFunc);
1757
+ */
1758
+ WINDOW_CALLBACK_DEFINE(SpecialFunc);
1759
+ WINDOW_CALLBACK_DEFINE(SpaceballMotionFunc);
1760
+ WINDOW_CALLBACK_DEFINE(SpaceballRotateFunc);
1761
+ WINDOW_CALLBACK_DEFINE(SpaceballButtonFunc);
1762
+ WINDOW_CALLBACK_DEFINE(ButtonBoxFunc);
1763
+ WINDOW_CALLBACK_DEFINE(DialsFunc);
1764
+ WINDOW_CALLBACK_DEFINE(TabletMotionFunc);
1765
+ WINDOW_CALLBACK_DEFINE(TabletButtonFunc);
1766
+ /*
1767
+ WINDOW_GLOBAL_VAR_DEFINE(MenuStatusFunc);
1768
+ */
1769
+ WINDOW_CALLBACK_DEFINE(OverlayDisplayFunc);
1770
+ WINDOW_CALLBACK_DEFINE(WindowStatusFunc);
1771
+
1772
+ rb_gc_register_address(&idle_func);
1773
+ rb_gc_register_address(&timer_func);
1774
+ rb_gc_register_address(&menustate_func);
1775
+ }
1776
+