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