ruby-opengl2 0.60.2

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