ruby-opengl 0.33.0

Sign up to get free protection for your applications and to get access to all the features.
data/ext/glu/glu.c ADDED
@@ -0,0 +1,1636 @@
1
+ /*
2
+ * Last edit by previous maintainer:
3
+ * 2003/10/25 15:25:05, yoshi
4
+ *
5
+ * Copyright (C) 1999 - 2005 Yoshi <yoshi@giganet.net>
6
+ * Copyright (C) 2006 John M. Gabriele <jmg3000@gmail.com>
7
+ *
8
+ * This program is distributed under the terms of the MIT license.
9
+ * See the included COPYRIGHT file for the terms of this license.
10
+ *
11
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
13
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
14
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
15
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
16
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
17
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18
+ */
19
+
20
+ #ifdef __APPLE__
21
+ #include <OpenGL/gl.h>
22
+ #include <OpenGL/glu.h>
23
+ #elif defined WIN32
24
+ #include <windows.h>
25
+ #include <GL/gl.h>
26
+ #include <GL/glu.h>
27
+ #else
28
+ #include <GL/gl.h>
29
+ #include <GL/glu.h>
30
+ #endif
31
+
32
+ #include <ruby.h>
33
+ #include "../common/rbogl.h"
34
+
35
+ #ifdef WIN32
36
+ typedef void (CALLBACK*(VOIDFUNC))();
37
+ #else
38
+ typedef void (*VOIDFUNC)();
39
+ #endif
40
+
41
+ #if defined(GLU_VERSION_1_2)
42
+ typedef GLUtesselator tesselatorObj;
43
+ #else /* GLU_VERSION_1_2 */
44
+ typedef GLUtriangulatorObj tesselatorObj;
45
+ #endif /* !GLU_VERSION_1_2 */
46
+
47
+ #ifdef MESA
48
+ struct glu_MesaStack {
49
+ int len;
50
+ GLfloat **ptr;
51
+ };
52
+
53
+ static struct glu_MesaStack gms = {0, NULL};
54
+ #endif
55
+
56
+ struct nurbsdata {
57
+ GLUnurbsObj *nobj;
58
+ };
59
+ struct tessdata {
60
+ tesselatorObj *tobj;
61
+ VALUE t_ref;
62
+ };
63
+
64
+ struct quaddata {
65
+ GLUquadricObj *qobj;
66
+ };
67
+
68
+ static VALUE cNurbs;
69
+ static VALUE cTess;
70
+ static VALUE cQuad;
71
+
72
+ #define GetNURBS(obj, ndata) {\
73
+ Data_Get_Struct(obj, struct nurbsdata, ndata);\
74
+ if (ndata->nobj == NULL) rb_raise(rb_eRuntimeError, "Nurbs Object already deleted!");\
75
+ }
76
+
77
+ #define GetTESS(obj, tdata) {\
78
+ Data_Get_Struct(obj, struct tessdata, tdata);\
79
+ if (tdata->tobj == NULL) rb_raise(rb_eRuntimeError, "Triangulator Object already deleted!");\
80
+ }
81
+
82
+ #define GetQUAD(obj, qdata) {\
83
+ Data_Get_Struct(obj, struct quaddata, qdata);\
84
+ if (qdata->qobj == NULL) rb_raise(rb_eRuntimeError, "Quadric Object already deleted!");\
85
+ }
86
+
87
+ static ID callId;
88
+ static ID refId;
89
+
90
+ /*
91
+ * GLU Implementation
92
+ */
93
+
94
+ /*
95
+ * Nurbs
96
+ */
97
+ /* from nurbscrv.c */
98
+ static int
99
+ get_curve_dim(type)
100
+ GLenum type;
101
+ {
102
+ switch(type)
103
+ {
104
+ case GL_MAP1_VERTEX_3: return 3;
105
+ case GL_MAP1_VERTEX_4: return 4;
106
+ case GL_MAP1_INDEX: return 1;
107
+ case GL_MAP1_COLOR_4: return 4;
108
+ case GL_MAP1_NORMAL: return 3;
109
+ case GL_MAP1_TEXTURE_COORD_1: return 1;
110
+ case GL_MAP1_TEXTURE_COORD_2: return 2;
111
+ case GL_MAP1_TEXTURE_COORD_3: return 3;
112
+ case GL_MAP1_TEXTURE_COORD_4: return 4;
113
+ default: abort(); /* TODO: is this OK? */
114
+ }
115
+ return 0; /*never get here*/
116
+ }
117
+ /* from nurbssrf.c */
118
+ static int
119
+ get_surface_dim(GLenum type)
120
+ {
121
+ switch(type)
122
+ {
123
+ case GL_MAP2_VERTEX_3: return 3;
124
+ case GL_MAP2_VERTEX_4: return 4;
125
+ case GL_MAP2_INDEX: return 1;
126
+ case GL_MAP2_COLOR_4: return 4;
127
+ case GL_MAP2_NORMAL: return 3;
128
+ case GL_MAP2_TEXTURE_COORD_1: return 1;
129
+ case GL_MAP2_TEXTURE_COORD_2: return 2;
130
+ case GL_MAP2_TEXTURE_COORD_3: return 3;
131
+ case GL_MAP2_TEXTURE_COORD_4: return 4;
132
+ default: abort(); /* TODO: is this OK? */
133
+ }
134
+ return 0; /*never get here*/
135
+ }
136
+
137
+ /*
138
+ * NURBS API
139
+ */
140
+ static void
141
+ free_nurbs(ndata)
142
+ struct nurbsdata *ndata;
143
+ {
144
+ if (ndata->nobj) gluDeleteNurbsRenderer(ndata->nobj);
145
+ ndata->nobj = NULL;
146
+ }
147
+ static VALUE
148
+ glu_NewNurbsRenderer(obj)
149
+ VALUE obj;
150
+ {
151
+ VALUE ret;
152
+ struct nurbsdata *ndata;
153
+ ret = Data_Make_Struct(cNurbs, struct nurbsdata, 0, free_nurbs, ndata);
154
+ ndata->nobj = gluNewNurbsRenderer();
155
+ return ret;
156
+ }
157
+ static VALUE
158
+ glu_DeleteNurbsRenderer(obj, arg1)
159
+ VALUE obj, arg1;
160
+ {
161
+ struct nurbsdata *ndata;
162
+ GetNURBS(arg1, ndata);
163
+ free_nurbs(ndata);
164
+ return Qnil;
165
+ }
166
+ static VALUE
167
+ glu_NurbsProperty(obj, arg1, arg2, arg3)
168
+ VALUE obj, arg1, arg2, arg3;
169
+ {
170
+ struct nurbsdata *ndata;
171
+ GLenum property;
172
+ GLfloat value;
173
+ GetNURBS(arg1, ndata);
174
+ property = (GLenum)NUM2INT(arg2);
175
+ value = (GLfloat)NUM2DBL(arg3);
176
+ gluNurbsProperty(ndata->nobj, property, value);
177
+ return Qnil;
178
+ }
179
+ static VALUE
180
+ glu_GetNurbsProperty(obj, arg1, arg2)
181
+ VALUE obj, arg1, arg2;
182
+ {
183
+ struct nurbsdata *ndata;
184
+ GLenum property;
185
+ GLfloat value;
186
+ GetNURBS(arg1, ndata);
187
+ property = (GLenum)NUM2INT(arg2);
188
+ gluGetNurbsProperty(ndata->nobj, property, &value);
189
+ return rb_float_new(value);
190
+ }
191
+ static VALUE
192
+ glu_BeginCurve(obj, arg1)
193
+ VALUE obj, arg1;
194
+ {
195
+ struct nurbsdata *ndata;
196
+ GetNURBS(arg1, ndata);
197
+ gluBeginCurve(ndata->nobj);
198
+ return Qnil;
199
+ }
200
+ static VALUE
201
+ glu_EndCurve(obj, arg1)
202
+ VALUE obj, arg1;
203
+ {
204
+ struct nurbsdata *ndata;
205
+ GetNURBS(arg1, ndata);
206
+ gluEndCurve(ndata->nobj);
207
+ /* hack for Mesa 3.1 */
208
+ #ifdef MESA
209
+ for (gms.len;gms.len>0;gms.len--)
210
+ free(gms.ptr[gms.len-1]);
211
+ free(gms.ptr);
212
+ gms.ptr = NULL;
213
+ #endif
214
+ return Qnil;
215
+ }
216
+ static VALUE
217
+ glu_NurbsCurve(argc,argv,obj)
218
+ int argc;
219
+ VALUE *argv;
220
+ VALUE obj;
221
+ {
222
+ struct nurbsdata *ndata;
223
+ GLint uknot_count;
224
+ GLfloat *uknot;
225
+ GLint u_stride;
226
+ GLint uorder;
227
+ GLfloat *ctlarray;
228
+ GLenum type;
229
+
230
+ VALUE args[7];
231
+ GLfloat tmp[4];
232
+ int i;
233
+ struct RArray *ary_ctl1;
234
+
235
+ switch (rb_scan_args(argc, argv, "43", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5], &args[6])) {
236
+ case 3:
237
+ uknot_count = RARRAY(rb_Array(args[1]))->len;
238
+ uknot = ALLOC_N(GLfloat, uknot_count);
239
+ ary2cflt(args[1], uknot, uknot_count);
240
+ ary_ctl1 = RARRAY(rb_Array(args[2]));
241
+ type = (GLenum)NUM2INT(args[3]);
242
+ u_stride = get_curve_dim(type);
243
+ uorder = ary_ctl1->len;
244
+ ctlarray = ALLOC_N(GLfloat, u_stride*uorder);
245
+ for (i = 0; i < ary_ctl1->len; i++) {
246
+ ary2cflt(ary_ctl1->ptr[i], tmp, 4);
247
+ memcpy(&ctlarray[i*u_stride], tmp, u_stride);
248
+ }
249
+ break;
250
+ case 7:
251
+ uknot_count = (GLint)NUM2INT(args[1]);
252
+ uknot = ALLOC_N(GLfloat, uknot_count);
253
+ ary2cflt(args[2], uknot, uknot_count);
254
+ u_stride = (GLint)NUM2INT(args[3]);
255
+ uorder = (GLint)NUM2INT(args[5]);
256
+ type = (GLenum)NUM2INT(args[6]); /* ---> line was missing */
257
+ /* ctlarray = ALLOC_N(GLfloat, u_stride*uorder); //--->Mathematically incorrect */
258
+ ctlarray = ALLOC_N(GLfloat, u_stride*(uknot_count-uorder));
259
+ ary_ctl1 = RARRAY(rb_Array(args[4]));
260
+ if (TYPE(ary_ctl1->ptr[0]) == T_ARRAY)
261
+ for (i = 0; i < ary_ctl1->len; i++) {
262
+ ary2cflt(ary_ctl1->ptr[i], tmp, 4);
263
+ memcpy(&ctlarray[i*u_stride], tmp, u_stride);
264
+ }
265
+ else {
266
+ /* ary2cflt((VALUE)ary_ctl1, ctlarray, u_stride*uorder); //--->Mathematically incorrect */
267
+ ary2cflt((VALUE)ary_ctl1, ctlarray, (uknot_count-uorder)*u_stride);
268
+ }
269
+ break;
270
+ default:
271
+ rb_raise(rb_eArgError, "arg num:%d",argc);
272
+ }
273
+ GetNURBS(args[0], ndata);
274
+ gluNurbsCurve(ndata->nobj, uknot_count, uknot, u_stride, ctlarray, uorder, type);
275
+ /* as of Mesa 3.1, Mesa assumes all data that following pointers
276
+ points to is valid at gluEndCurve. so, free them in
277
+ glu_EndCurve() */
278
+ #ifdef MESA
279
+ gms.ptr = REALLOC_N(gms.ptr, GLfloat*, gms.len+=2);
280
+ gms.ptr[gms.len - 2] = uknot;
281
+ gms.ptr[gms.len - 1] = ctlarray;
282
+ #else
283
+ free(uknot);
284
+ free(ctlarray);
285
+ #endif
286
+ return Qnil;
287
+ }
288
+ static VALUE
289
+ glu_BeginSurface(obj, arg1)
290
+ VALUE obj, arg1;
291
+ {
292
+ struct nurbsdata *ndata;
293
+ GetNURBS(arg1, ndata);
294
+ gluBeginSurface(ndata->nobj);
295
+ return Qnil;
296
+ }
297
+ static VALUE
298
+ glu_EndSurface(obj, arg1)
299
+ VALUE obj, arg1;
300
+ {
301
+ struct nurbsdata *ndata;
302
+ GetNURBS(arg1, ndata);
303
+ gluEndSurface(ndata->nobj);
304
+ /* hack for Mesa 3.1 */
305
+ #ifdef MESA
306
+ for(gms.len; gms.len>0; gms.len--)
307
+ free(gms.ptr[gms.len-1]);
308
+ free(gms.ptr);
309
+ gms.ptr = NULL;
310
+ #endif
311
+ return Qnil;
312
+ }
313
+
314
+ static VALUE
315
+ glu_NurbsSurface(argc, argv, obj)
316
+ int argc;
317
+ VALUE *argv;
318
+ VALUE obj;
319
+ {
320
+ struct nurbsdata *ndata;
321
+ GLint sknot_count;
322
+ GLfloat *sknot;
323
+ GLint tknot_count;
324
+ GLfloat *tknot;
325
+ GLint s_stride;
326
+ GLint t_stride;
327
+ GLfloat *ctlarray;
328
+ GLint sorder;
329
+ GLint torder;
330
+ GLenum type;
331
+ VALUE work_ary;
332
+
333
+ VALUE args[11];
334
+ struct RArray *ary_ctl1;
335
+ int type_len;
336
+
337
+ switch (rb_scan_args(argc, argv, "56", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5], &args[6], &args[7], &args[8], &args[9], &args[10])) {
338
+ case 5:
339
+ sknot_count = RARRAY(rb_Array(args[1]))->len;
340
+ sknot = ALLOC_N(GLfloat, sknot_count);
341
+ ary2cflt(args[1], sknot, sknot_count);
342
+ tknot_count = RARRAY(rb_Array(args[2]))->len;
343
+ tknot = ALLOC_N(GLfloat, tknot_count);
344
+ ary2cflt(args[2], tknot, tknot_count);
345
+ ary_ctl1 = RARRAY(rb_Array(args[3]));
346
+ sorder = ary_ctl1->len;
347
+ torder = RARRAY(rb_Array(ary_ctl1->ptr[0]))->len;
348
+ type = (GLenum)NUM2INT(args[4]);
349
+ t_stride = get_surface_dim(type);
350
+ s_stride = t_stride * sorder;
351
+ ctlarray = ALLOC_N(GLfloat, t_stride*s_stride);
352
+ work_ary = rb_ary_new();
353
+ mary2ary((VALUE)ary_ctl1, work_ary);
354
+ ary2cflt(work_ary, ctlarray, t_stride*s_stride);
355
+ case 11:
356
+ sknot_count = (GLint)NUM2INT(args[1]);
357
+ sknot = ALLOC_N(GLfloat, sknot_count);
358
+ ary2cflt(args[2], sknot, sknot_count);
359
+ tknot_count = (GLint)NUM2INT(args[3]);
360
+ tknot = ALLOC_N(GLfloat, tknot_count);
361
+ ary2cflt(args[4], tknot, tknot_count);
362
+ s_stride = (GLint)NUM2INT(args[5]);
363
+ t_stride = (GLint)NUM2INT(args[6]);
364
+ sorder = (GLint)NUM2INT(args[8]);
365
+ torder = (GLint)NUM2INT(args[9]);
366
+ type = (GLint)NUM2INT(args[10]);
367
+ type_len = get_surface_dim(type);
368
+ /* ctlarray = ALLOC_N(GLfloat, sorder*torder*type_len); //--->Mathematically incorrect */
369
+ ctlarray = ALLOC_N(GLfloat, (sknot_count-sorder)*(tknot_count-torder)*type_len);
370
+ ary_ctl1 = RARRAY(rb_Array(args[7]));
371
+ if (TYPE(ary_ctl1->ptr[0]) == T_ARRAY) {
372
+ work_ary = rb_ary_new();
373
+ mary2ary((VALUE)ary_ctl1, work_ary);
374
+ /* ary2cflt(work_ary, ctlarray, sorder*torder*type_len); //--->Mathematically incorrect */
375
+ ary2cflt(work_ary, ctlarray, (sknot_count-sorder)*(tknot_count-torder)*type_len);
376
+ }
377
+ else {
378
+ /* ary2cflt((VALUE)ary_ctl1, ctlarray, sorder*torder*type_len); //--->Mathematically incorrect */
379
+ ary2cflt((VALUE)ary_ctl1, ctlarray, (sknot_count-sorder)*(tknot_count-torder)*type_len);
380
+ }
381
+ break;
382
+ default:
383
+ rb_raise(rb_eArgError, "arg num:%d",argc);
384
+ }
385
+ GetNURBS(args[0], ndata);
386
+ gluNurbsSurface(ndata->nobj, sknot_count, sknot, tknot_count, tknot,
387
+ s_stride, t_stride, ctlarray, sorder, torder, type);
388
+
389
+ /* as of Mesa 3.1, Mesa assumes all data that following pointers
390
+ points to is valid at gluEndSurface. so, free them in
391
+ glu_EndSurface() */
392
+ #ifdef MESA
393
+ gms.ptr = REALLOC_N(gms.ptr, GLfloat*, gms.len+=3);
394
+ gms.ptr[gms.len-3] = sknot;
395
+ gms.ptr[gms.len-2] = tknot;
396
+ gms.ptr[gms.len-1] = ctlarray;
397
+ #else
398
+ free(sknot);
399
+ free(tknot);
400
+ free(ctlarray);
401
+ #endif
402
+ return Qnil;
403
+ }
404
+ static VALUE
405
+ glu_BeginTrim(obj, arg1)
406
+ VALUE obj, arg1;
407
+ {
408
+ struct nurbsdata *ndata;
409
+ GetNURBS(arg1, ndata);
410
+ gluBeginTrim(ndata->nobj);
411
+ return Qnil;
412
+ }
413
+ static VALUE
414
+ glu_EndTrim(obj, arg1)
415
+ VALUE obj, arg1;
416
+ {
417
+ struct nurbsdata *ndata;
418
+ GetNURBS(arg1, ndata);
419
+ gluEndTrim(ndata->nobj);
420
+ return Qnil;
421
+ }
422
+ static VALUE
423
+ glu_PwlCurve(argc, argv, obj)
424
+ int argc;
425
+ VALUE *argv;
426
+ VALUE obj;
427
+ {
428
+ struct nurbsdata *ndata;
429
+ GLint count;
430
+ GLfloat *array;
431
+ GLint stride;
432
+ GLenum type;
433
+
434
+ VALUE args[5];
435
+ GLfloat tmp[3];
436
+ struct RArray* ary_ctl1;
437
+ int i;
438
+
439
+ switch (rb_scan_args(argc, argv, "32", &args[0], &args[1], &args[2], &args[3], &args[4])) {
440
+ case 3:
441
+ ary_ctl1 = RARRAY(rb_Array(args[2]));
442
+ count = ary_ctl1->len;
443
+ type = NUM2INT(args[2]);
444
+ stride = (type == GLU_MAP1_TRIM_2 ? 2 : 3);
445
+ array = ALLOC_N(GLfloat, count*stride);
446
+ for (i = 0; i < ary_ctl1->len; i++) {
447
+ ary2cflt(ary_ctl1->ptr[i], tmp, 3);
448
+ memcpy(&array[i*stride], tmp, stride);
449
+ }
450
+ break;
451
+ case 5:
452
+ count = NUM2INT(args[1]);
453
+ stride = NUM2INT(args[3]);
454
+ type = NUM2INT(args[4]);
455
+ array = ALLOC_N(GLfloat, count*stride);
456
+ ary_ctl1 = RARRAY(rb_Array(args[2]));
457
+ if (TYPE(ary_ctl1->ptr[0]) == T_ARRAY)
458
+ for (i = 0; i < ary_ctl1->len; i++) {
459
+ ary2cflt(ary_ctl1->ptr[i], tmp, 3);
460
+ memcpy(&array[i*stride], tmp, stride);
461
+ }
462
+ else
463
+ ary2cflt((VALUE)ary_ctl1, array, count*stride);
464
+ break;
465
+ default:
466
+ rb_raise(rb_eArgError, "arg num:%d",argc);
467
+ }
468
+ GetNURBS(args[0], ndata);
469
+ gluPwlCurve(ndata->nobj, count, array, stride, type);
470
+ free(array);
471
+ return Qnil;
472
+ }
473
+
474
+ /*
475
+ * Tesselation API
476
+ */
477
+ static VALUE t_current;
478
+ #define TESS_DATA 0
479
+ #define TESS_BEGIN 1
480
+ #define TESS_VERTEX 2
481
+ #define TESS_END 3
482
+ #define TESS_ERROR 4
483
+ #define TESS_EDGE 5
484
+ #if defined(GLU_VERSION_1_2)
485
+ # define TESS_OUTDATA 6
486
+ # define TESS_COMBINE 7
487
+ # define TESS_BEGIN_DATA 8
488
+ # define TESS_VERTEX_DATA 9
489
+ # define TESS_END_DATA 10
490
+ # define TESS_ERROR_DATA 11
491
+ # define TESS_EDGE_DATA 12
492
+ # define TESS_COMBINE_DATA 13
493
+ # define TESS_USERDATA 14
494
+ # define REF_LAST 15
495
+ #else /* !GLU_VERSION_1_2 */
496
+ # define REF_LAST 6
497
+ #endif /* GLU_VERSION_1_2 */
498
+ static void
499
+ mark_tess(tdata)
500
+ struct tessdata* tdata;
501
+ {
502
+ if (tdata->tobj)
503
+ rb_gc_mark(tdata->t_ref);
504
+ }
505
+ static void
506
+ free_tess(tdata)
507
+ struct tessdata *tdata;
508
+ {
509
+ ID id;
510
+ VALUE call_key;
511
+
512
+ if (tdata->tobj) {
513
+ gluDeleteTess(tdata->tobj);
514
+ }
515
+ tdata->t_ref = Qnil;
516
+ tdata->tobj = NULL;
517
+ }
518
+ static VALUE
519
+ glu_NewTess(obj)
520
+ VALUE obj;
521
+ {
522
+ VALUE ret;
523
+ struct tessdata *tdata;
524
+ ret = Data_Make_Struct(cTess, struct tessdata, mark_tess, free_tess, tdata);
525
+ tdata->tobj = gluNewTess();
526
+ tdata->t_ref = rb_ary_new2(REF_LAST);
527
+ return ret;
528
+ }
529
+ static VALUE
530
+ glu_DeleteTess(obj, arg1)
531
+ VALUE obj, arg1;
532
+ {
533
+ struct tessdata *tdata;
534
+ GetTESS(arg1, tdata);
535
+ free_tess(tdata);
536
+ return Qnil;
537
+ }
538
+ void
539
+ t_begin(type)
540
+ GLenum type;
541
+ {
542
+ VALUE tess;
543
+ struct tessdata *tdata;
544
+ tess = rb_ary_entry(t_current, -1);
545
+ if (tess != Qnil) {
546
+ GetTESS(tess, tdata);
547
+ rb_funcall(rb_ary_entry(tdata->t_ref, TESS_BEGIN), callId, 1, INT2NUM(type));
548
+ }
549
+ }
550
+ static void
551
+ t_edgeFlag(flag)
552
+ GLboolean flag;
553
+ {
554
+ VALUE tess;
555
+ struct tessdata *tdata;
556
+ tess = rb_ary_entry(t_current, -1);
557
+ if (tess != Qnil) {
558
+ GetTESS(tess, tdata);
559
+ rb_funcall(rb_ary_entry(tdata->t_ref, TESS_EDGE), callId, 1, INT2NUM(flag));
560
+ }
561
+ }
562
+ static void
563
+ t_vertex(data)
564
+ void* data;
565
+ {
566
+ VALUE tess;
567
+ struct tessdata *tdata;
568
+ tess = rb_ary_entry(t_current, -1);
569
+ if (tess != Qnil) {
570
+ GetTESS(tess, tdata);
571
+ rb_funcall(rb_ary_entry(tdata->t_ref, TESS_VERTEX), callId, 1, data);
572
+ }
573
+ }
574
+ static void
575
+ t_end()
576
+ {
577
+ VALUE tess;
578
+ struct tessdata *tdata;
579
+ tess = rb_ary_entry(t_current, -1);
580
+ if (tess != Qnil) {
581
+ GetTESS(tess, tdata);
582
+ rb_funcall(rb_ary_entry(tdata->t_ref, TESS_END), callId, 0);
583
+ }
584
+ }
585
+ static void
586
+ t_error(errorno)
587
+ GLenum errorno;
588
+ {
589
+ VALUE tess;
590
+ struct tessdata *tdata;
591
+ tess = rb_ary_entry(t_current, -1);
592
+ if (tess != Qnil) {
593
+ GetTESS(tess, tdata);
594
+ rb_funcall(rb_ary_entry(tdata->t_ref, TESS_ERROR), callId, 1, INT2NUM(errorno));
595
+ }
596
+ }
597
+
598
+ #if defined(GLU_VERSION_1_2)
599
+ static void
600
+ t_begin_data(type, user_data)
601
+ GLenum type;
602
+ void* user_data;
603
+ {
604
+ VALUE tess;
605
+ struct tessdata *tdata;
606
+ tess = rb_ary_entry(t_current, -1);
607
+ if (tess != Qnil) {
608
+ GetTESS(tess, tdata);
609
+ rb_funcall(rb_ary_entry(tdata->t_ref, TESS_BEGIN_DATA), callId, 2, INT2NUM(type), user_data);
610
+ }
611
+ }
612
+ static void
613
+ t_edgeFlag_data(flag, user_data)
614
+ GLboolean flag;
615
+ void* user_data;
616
+ {
617
+ VALUE tess;
618
+ struct tessdata *tdata;
619
+ tess = rb_ary_entry(t_current, -1);
620
+ if (tess != Qnil) {
621
+ GetTESS(tess, tdata);
622
+ rb_funcall(rb_ary_entry(tdata->t_ref, TESS_EDGE_DATA), callId, 2, INT2NUM(flag), user_data);
623
+ }
624
+ }
625
+ static void
626
+ t_vertex_data(data, user_data)
627
+ void* data;
628
+ void* user_data;
629
+ {
630
+ VALUE tess;
631
+ struct tessdata *tdata;
632
+ tess = rb_ary_entry(t_current, -1);
633
+ if (tess != Qnil) {
634
+ GetTESS(tess, tdata);
635
+ rb_funcall(rb_ary_entry(tdata->t_ref, TESS_VERTEX_DATA), callId, 2, data, user_data);
636
+ }
637
+ }
638
+ static void
639
+ t_end_data(user_data)
640
+ void* user_data;
641
+ {
642
+ VALUE tess;
643
+ struct tessdata *tdata;
644
+ tess = rb_ary_entry(t_current, -1);
645
+ if (tess != Qnil) {
646
+ GetTESS(tess, tdata);
647
+ rb_funcall(rb_ary_entry(tdata->t_ref, TESS_END_DATA), callId, 1, user_data);
648
+ }
649
+ }
650
+ static void
651
+ t_error_data(errorno, user_data)
652
+ GLenum errorno;
653
+ void* user_data;
654
+ {
655
+ VALUE tess;
656
+ struct tessdata *tdata;
657
+ tess = rb_ary_entry(t_current, -1);
658
+ if (tess != Qnil) {
659
+ GetTESS(tess, tdata);
660
+ rb_funcall(rb_ary_entry(tdata->t_ref, TESS_ERROR_DATA), callId, 2, INT2NUM(errorno), user_data);
661
+ }
662
+ }
663
+ static void
664
+ t_combine(coords, vertex_data, weight, outData)
665
+ GLdouble coords[3];
666
+ void* vertex_data[4];
667
+ GLfloat weight[4];
668
+ void** outData;
669
+ {
670
+ VALUE tess;
671
+ struct tessdata *tdata;
672
+ VALUE rb_coord, rb_vertex_data, rb_weight;
673
+ int i;
674
+ tess = rb_ary_entry(t_current, -1);
675
+ if (tess != Qnil) {
676
+ GetTESS(tess, tdata);
677
+ rb_coord = rb_ary_new2(3);
678
+ for (i = 0; i < 3; i++)
679
+ rb_ary_store(rb_coord, i, rb_float_new(coords[i]));
680
+ rb_vertex_data = rb_ary_new2(4);
681
+ for (i = 0; i < 4; i++)
682
+ rb_ary_store(rb_vertex_data, i, (VALUE)vertex_data[i]);
683
+ rb_weight = rb_ary_new2(4);
684
+ for (i = 0; i < 4; i++)
685
+ rb_ary_store(rb_weight, i, rb_float_new(weight[i]));
686
+ *outData = (void*)rb_funcall(rb_ary_entry(tdata->t_ref, TESS_COMBINE), callId, 3, rb_coord, rb_vertex_data, rb_weight);
687
+ rb_ary_push(rb_ary_entry(tdata->t_ref, TESS_OUTDATA), (VALUE)*outData);
688
+ }
689
+ }
690
+ static void
691
+ t_combine_data(coords, vertex_data, weight, outData, user_data)
692
+ GLdouble coords[3];
693
+ void* vertex_data[4];
694
+ GLfloat weight[4];
695
+ void** outData;
696
+ void* user_data;
697
+ {
698
+ VALUE tess;
699
+ struct tessdata *tdata;
700
+ VALUE rb_coord, rb_vertex_data, rb_weight;
701
+ int i;
702
+ tess = rb_ary_entry(t_current, -1);
703
+ if (tess != Qnil) {
704
+ GetTESS(tess, tdata);
705
+ rb_coord = rb_ary_new2(3);
706
+ for (i = 0; i < 3; i++)
707
+ rb_ary_store(rb_coord, i, rb_float_new(coords[i]));
708
+ rb_vertex_data = rb_ary_new2(4);
709
+ for (i = 0; i < 4; i++)
710
+ rb_ary_store(rb_vertex_data, i, (VALUE)vertex_data[i]);
711
+ rb_weight = rb_ary_new2(4);
712
+ for (i = 0; i < 4; i++)
713
+ rb_ary_store(rb_weight, i, rb_float_new(weight[i]));
714
+ *outData = (void*)rb_funcall(rb_ary_entry(tdata->t_ref, TESS_COMBINE_DATA), callId, 4, rb_coord, rb_vertex_data, rb_weight, (VALUE)user_data);
715
+ rb_ary_push(rb_ary_entry(tdata->t_ref, TESS_OUTDATA), (VALUE)*outData);
716
+ }
717
+ }
718
+ static VALUE
719
+ glu_TessProperty(obj, arg1, arg2, arg3)
720
+ VALUE obj, arg1, arg2;
721
+ {
722
+ struct tessdata* tdata;
723
+ GLenum property;
724
+ GLdouble value;
725
+ GetTESS(arg1, tdata);
726
+ property = (GLenum)NUM2INT(arg2);
727
+ value = (GLdouble)NUM2DBL(arg3);
728
+ gluTessProperty(tdata->tobj, property, value);
729
+ return Qnil;
730
+ }
731
+ static VALUE
732
+ glu_GetTessProperty(obj, arg1, arg2)
733
+ VALUE obj, arg1, arg2;
734
+ {
735
+ struct tessdata* tdata;
736
+ GLenum property;
737
+ GLdouble value;
738
+ GetTESS(arg1, tdata);
739
+ property = (GLenum)NUM2INT(arg2);
740
+ gluGetTessProperty(tdata->tobj, property, &value);
741
+ return rb_float_new(value);
742
+ }
743
+ static VALUE
744
+ glu_TessNormal(obj, arg1, arg2, arg3, arg4)
745
+ VALUE obj, arg1, arg2, arg3, arg4;
746
+ {
747
+ struct tessdata* tdata;
748
+ GLdouble x, y, z;
749
+ GetTESS(arg1, tdata);
750
+ x = (GLdouble)NUM2DBL(arg2);
751
+ y = (GLdouble)NUM2DBL(arg3);
752
+ z = (GLdouble)NUM2DBL(arg4);
753
+ gluTessNormal(tdata->tobj, x, y, z);
754
+ return Qnil;
755
+ }
756
+ static VALUE
757
+ glu_TessBeginPolygon(obj, arg1, arg2)
758
+ VALUE obj, arg1, arg2;
759
+ {
760
+ struct tessdata* tdata;
761
+ GetTESS(arg1, tdata);
762
+ rb_ary_store(tdata->t_ref, TESS_USERDATA, arg2);
763
+ rb_ary_store(tdata->t_ref, TESS_OUTDATA, rb_ary_new());
764
+ rb_ary_store(tdata->t_ref, TESS_DATA, rb_ary_new());
765
+ rb_ary_push(t_current, arg1);
766
+ gluTessBeginPolygon(tdata->tobj, (void*)arg2);
767
+ return Qnil;
768
+ }
769
+ static VALUE
770
+ glu_TessEndPolygon(obj, arg1)
771
+ VALUE obj, arg1;
772
+ {
773
+ struct tessdata* tdata;
774
+ GetTESS(arg1, tdata);
775
+ gluTessEndPolygon(tdata->tobj);
776
+ rb_ary_store(tdata->t_ref, TESS_USERDATA, Qnil);
777
+ rb_ary_store(tdata->t_ref, TESS_OUTDATA, Qnil);
778
+ rb_ary_store(tdata->t_ref, TESS_DATA, Qnil);
779
+ rb_ary_pop(t_current);
780
+ return Qnil;
781
+ }
782
+ static VALUE
783
+ glu_TessBeginContour(obj, arg1)
784
+ VALUE obj, arg1;
785
+ {
786
+ struct tessdata* tdata;
787
+ GetTESS(arg1, tdata);
788
+ gluTessBeginContour(tdata->tobj);
789
+ return Qnil;
790
+ }
791
+ static VALUE
792
+ glu_TessEndContour(obj, arg1)
793
+ {
794
+ struct tessdata* tdata;
795
+ GetTESS(arg1, tdata);
796
+ gluTessEndContour(tdata->tobj);
797
+ return Qnil;
798
+ }
799
+ #endif /* GLU_VERSION_1_2 */
800
+
801
+ static VALUE
802
+ glu_TessCallback(obj, arg1, arg2, arg3)
803
+ VALUE obj, arg1, arg2, arg3;
804
+ {
805
+ struct tessdata* tdata;
806
+ GLenum type;
807
+ ID id;
808
+ GetTESS(arg1, tdata);
809
+ type = (GLenum)NUM2INT(arg2);
810
+ id = rb_intern("[]=");
811
+ if (!rb_obj_is_kind_of(arg3,rb_cProc) && NIL_P(arg3))
812
+ rb_raise(rb_eTypeError, "GLU.TessCallback needs Proc Object:%s",rb_class2name(CLASS_OF(arg3)));
813
+
814
+ switch (type) {
815
+ #if defined(GLU_VERSION_1_2)
816
+ case GLU_TESS_BEGIN:
817
+ #else
818
+ case GLU_BEGIN:
819
+ #endif
820
+ rb_ary_store(tdata->t_ref, TESS_BEGIN, arg3);
821
+ if (NIL_P(arg3))
822
+ gluTessCallback(tdata->tobj, type, NULL);
823
+ else
824
+ gluTessCallback(tdata->tobj, type, (VOIDFUNC)(t_begin));
825
+ break;
826
+ #if defined(GLU_VERSION_1_2)
827
+ case GLU_TESS_EDGE_FLAG:
828
+ #else
829
+ case GLU_EDGE_FLAG:
830
+ #endif
831
+ rb_ary_store(tdata->t_ref, TESS_EDGE, arg3);
832
+ if (NIL_P(arg3))
833
+ gluTessCallback(tdata->tobj, type, NULL);
834
+ else
835
+ gluTessCallback(tdata->tobj, type, (VOIDFUNC)t_edgeFlag);
836
+ break;
837
+ #if defined(GLU_VERSION_1_2)
838
+ case GLU_TESS_VERTEX:
839
+ #else
840
+ case GLU_VERTEX:
841
+ #endif
842
+ rb_ary_store(tdata->t_ref, TESS_VERTEX, arg3);
843
+ if (NIL_P(arg3))
844
+ gluTessCallback(tdata->tobj, type, NULL);
845
+ else
846
+ gluTessCallback(tdata->tobj, type, (VOIDFUNC)t_vertex);
847
+ break;
848
+ #if defined(GLU_VERSION_1_2)
849
+ case GLU_TESS_END:
850
+ #else
851
+ case GLU_END:
852
+ #endif
853
+ rb_ary_store(tdata->t_ref, TESS_END, arg3);
854
+ if (NIL_P(arg3))
855
+ gluTessCallback(tdata->tobj, type, NULL);
856
+ else
857
+ gluTessCallback(tdata->tobj, type, (VOIDFUNC)t_end);
858
+ break;
859
+ #if defined(GLU_VERSION_1_2)
860
+ case GLU_TESS_ERROR:
861
+ #else
862
+ case GLU_ERROR:
863
+ #endif
864
+ rb_ary_store(tdata->t_ref, TESS_ERROR, arg3);
865
+ if (NIL_P(arg3))
866
+ gluTessCallback(tdata->tobj, type, NULL);
867
+ else
868
+ gluTessCallback(tdata->tobj, type, (VOIDFUNC)t_error);
869
+ break;
870
+ #if defined(GLU_VERSION_1_2)
871
+ case GLU_TESS_COMBINE:
872
+ rb_ary_store(tdata->t_ref, TESS_COMBINE, arg3);
873
+ if (NIL_P(arg3))
874
+ gluTessCallback(tdata->tobj, type, NULL);
875
+ else
876
+ gluTessCallback(tdata->tobj, type, (VOIDFUNC)(t_combine));
877
+ break;
878
+ case GLU_TESS_BEGIN_DATA:
879
+ rb_ary_store(tdata->t_ref, TESS_BEGIN_DATA, arg3);
880
+ if (NIL_P(arg3))
881
+ gluTessCallback(tdata->tobj, type, NULL);
882
+ else
883
+ gluTessCallback(tdata->tobj, type, (VOIDFUNC)(t_begin_data));
884
+ break;
885
+ case GLU_TESS_VERTEX_DATA:
886
+ rb_ary_store(tdata->t_ref, TESS_VERTEX_DATA, arg3);
887
+ if (NIL_P(arg3))
888
+ gluTessCallback(tdata->tobj, type, NULL);
889
+ else
890
+ gluTessCallback(tdata->tobj, type, (VOIDFUNC)(t_vertex_data));
891
+ break;
892
+ case GLU_TESS_END_DATA:
893
+ rb_ary_store(tdata->t_ref, TESS_END_DATA, arg3);
894
+ if (NIL_P(arg3))
895
+ gluTessCallback(tdata->tobj, type, NULL);
896
+ else
897
+ gluTessCallback(tdata->tobj, type, (VOIDFUNC)(t_end_data));
898
+ break;
899
+ case GLU_TESS_ERROR_DATA:
900
+ rb_ary_store(tdata->t_ref, TESS_ERROR_DATA, arg3);
901
+ if (NIL_P(arg3))
902
+ gluTessCallback(tdata->tobj, type, NULL);
903
+ else
904
+ gluTessCallback(tdata->tobj, type, (VOIDFUNC)(t_error_data));
905
+ break;
906
+ case GLU_TESS_EDGE_FLAG_DATA:
907
+ rb_ary_store(tdata->t_ref, TESS_EDGE_DATA, arg3);
908
+ if (NIL_P(arg3))
909
+ gluTessCallback(tdata->tobj, type, NULL);
910
+ else
911
+ gluTessCallback(tdata->tobj, type, (VOIDFUNC)(t_edgeFlag_data));
912
+ break;
913
+ case GLU_TESS_COMBINE_DATA:
914
+ rb_ary_store(tdata->t_ref, TESS_COMBINE_DATA, arg3);
915
+ if (NIL_P(arg3))
916
+ gluTessCallback(tdata->tobj, type, NULL);
917
+ else
918
+ gluTessCallback(tdata->tobj, type, (VOIDFUNC)(t_combine_data));
919
+ break;
920
+ #endif /* GLU_VERSION_1_2 */
921
+ }
922
+ return Qnil;
923
+ }
924
+ static VALUE
925
+ glu_BeginPolygon(obj, arg1)
926
+ VALUE obj, arg1;
927
+ {
928
+ struct tessdata* tdata;
929
+ GetTESS(arg1, tdata);
930
+ rb_ary_store(tdata->t_ref, TESS_DATA, rb_ary_new());
931
+ rb_ary_push(t_current, arg1);
932
+ gluBeginPolygon(tdata->tobj);
933
+ return Qnil;
934
+ }
935
+ static VALUE
936
+ glu_TessVertex(obj, arg1, arg2, arg3)
937
+ VALUE obj, arg1, arg2, arg3;
938
+ {
939
+ struct tessdata* tdata;
940
+ GLdouble v[3];
941
+ VALUE call_key;
942
+ ID id;
943
+ GetTESS(arg1, tdata);
944
+ rb_ary_push(rb_ary_entry(tdata->t_ref, TESS_DATA), arg3);
945
+ ary2cdbl(arg2, v, 3);
946
+ gluTessVertex(tdata->tobj, v,(void *)arg3);
947
+ return Qnil;
948
+ }
949
+ static VALUE
950
+ glu_NextContour(obj, arg1, arg2)
951
+ VALUE obj, arg1, arg2;
952
+ {
953
+ struct tessdata* tdata;
954
+ GLenum type;
955
+ GetTESS(arg1, tdata);
956
+ type = (GLenum)NUM2INT(arg2);
957
+ gluNextContour(tdata->tobj, type);
958
+ return Qnil;
959
+ }
960
+ static VALUE
961
+ glu_EndPolygon(obj, arg1)
962
+ VALUE obj, arg1;
963
+ {
964
+ struct tessdata* tdata;
965
+ GetTESS(arg1, tdata);
966
+ gluEndPolygon(tdata->tobj);
967
+ rb_ary_store(tdata->t_ref, TESS_DATA, Qnil);
968
+ rb_ary_pop(t_current);
969
+ return Qnil;
970
+ }
971
+
972
+ /*
973
+ * Quadric API
974
+ */
975
+ static void
976
+ free_quad(qdata)
977
+ struct quaddata *qdata;
978
+ {
979
+ if (qdata->qobj) gluDeleteQuadric(qdata->qobj);
980
+ qdata->qobj = NULL;
981
+ }
982
+ static VALUE
983
+ glu_NewQuadric(obj)
984
+ VALUE obj;
985
+ {
986
+ VALUE ret;
987
+ struct quaddata *qdata;
988
+ ret = Data_Make_Struct(cQuad, struct quaddata, 0, free_quad, qdata);
989
+ qdata->qobj = gluNewQuadric();
990
+ return ret;
991
+ }
992
+ static VALUE
993
+ glu_DeleteQuadric(obj, arg1)
994
+ VALUE obj, arg1;
995
+ {
996
+ struct quaddata *qdata;
997
+ GetQUAD(arg1, qdata);
998
+ free_quad(qdata);
999
+ return Qnil;
1000
+ }
1001
+ static VALUE
1002
+ glu_QuadricNormals(obj, arg1, arg2)
1003
+ VALUE obj, arg1, arg2;
1004
+ {
1005
+ struct quaddata* qdata;
1006
+ GLenum normals;
1007
+ GetQUAD(arg1, qdata);
1008
+ normals = (GLenum)NUM2INT(arg2);
1009
+ gluQuadricNormals(qdata->qobj, normals);
1010
+ return Qnil;
1011
+ }
1012
+ static VALUE
1013
+ glu_QuadricTexture(obj, arg1, arg2)
1014
+ VALUE obj, arg1, arg2;
1015
+ {
1016
+ struct quaddata* qdata;
1017
+ GLboolean textureCoords;
1018
+ GetQUAD(arg1, qdata);
1019
+ textureCoords = (GLboolean)NUM2INT(arg2);
1020
+ gluQuadricTexture(qdata->qobj, textureCoords);
1021
+ return Qnil;
1022
+ }
1023
+ static VALUE
1024
+ glu_QuadricOrientation(obj, arg1, arg2)
1025
+ VALUE obj, arg1, arg2;
1026
+ {
1027
+ struct quaddata* qdata;
1028
+ GLenum orientation;
1029
+ GetQUAD(arg1, qdata);
1030
+ orientation = (GLenum)NUM2INT(arg2);
1031
+ gluQuadricOrientation(qdata->qobj, orientation);
1032
+ return Qnil;
1033
+ }
1034
+ static VALUE
1035
+ glu_QuadricDrawStyle(obj, arg1, arg2)
1036
+ VALUE obj, arg1, arg2;
1037
+ {
1038
+ struct quaddata* qdata;
1039
+ GLenum drawStyle;
1040
+ GetQUAD(arg1, qdata);
1041
+ drawStyle = (GLenum)NUM2INT(arg2);
1042
+ gluQuadricDrawStyle(qdata->qobj, drawStyle);
1043
+ return Qnil;
1044
+ }
1045
+ static VALUE
1046
+ glu_Cylinder(obj, arg1, arg2, arg3, arg4, arg5, arg6)
1047
+ VALUE obj, arg1, arg2, arg3, arg4, arg5, arg6;
1048
+ {
1049
+ struct quaddata* qdata;
1050
+ GLdouble baseRadius;
1051
+ GLdouble topRadius;
1052
+ GLdouble height;
1053
+ GLint slices;
1054
+ GLint stacks;
1055
+
1056
+ GetQUAD(arg1, qdata);
1057
+ baseRadius = (GLdouble)NUM2DBL(arg2);
1058
+ topRadius = (GLdouble)NUM2DBL(arg3);
1059
+ height = (GLdouble)NUM2DBL(arg4);
1060
+ slices = (GLint)NUM2INT(arg5);
1061
+ stacks = (GLint)NUM2INT(arg6);
1062
+
1063
+ gluCylinder(qdata->qobj, baseRadius, topRadius, height, slices, stacks);
1064
+ return Qnil;
1065
+ }
1066
+ static VALUE
1067
+ glu_Disk(obj, arg1, arg2, arg3, arg4, arg5)
1068
+ VALUE obj, arg1, arg2, arg3, arg4, arg5;
1069
+ {
1070
+ struct quaddata* qdata;
1071
+ GLdouble innerRadius;
1072
+ GLdouble outerRadius;
1073
+ GLint slices;
1074
+ GLint loops;
1075
+
1076
+ GetQUAD(arg1, qdata);
1077
+ innerRadius = (GLdouble)NUM2DBL(arg2);
1078
+ outerRadius = (GLdouble)NUM2DBL(arg3);
1079
+ slices = (GLint)NUM2INT(arg4);
1080
+ loops = (GLint)NUM2INT(arg5);
1081
+
1082
+ gluDisk(qdata->qobj, innerRadius, outerRadius, slices, loops);
1083
+ return Qnil;
1084
+ }
1085
+ static VALUE
1086
+ glu_PartialDisk(obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
1087
+ VALUE obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7;
1088
+ {
1089
+ struct quaddata* qdata;
1090
+ GLdouble innerRadius;
1091
+ GLdouble outerRadius;
1092
+ GLint slices;
1093
+ GLint loops;
1094
+ GLdouble startAngle;
1095
+ GLdouble sweepAngle;
1096
+
1097
+ GetQUAD(arg1, qdata);
1098
+ innerRadius = (GLdouble)NUM2DBL(arg2);
1099
+ outerRadius = (GLdouble)NUM2DBL(arg3);
1100
+ slices = (GLint)NUM2INT(arg4);
1101
+ loops = (GLint)NUM2INT(arg5);
1102
+ startAngle = (GLdouble)NUM2DBL(arg6);
1103
+ sweepAngle = (GLdouble)NUM2DBL(arg7);
1104
+
1105
+ gluPartialDisk(qdata->qobj, innerRadius, outerRadius, slices, loops, startAngle, sweepAngle);
1106
+ return Qnil;
1107
+ }
1108
+ static VALUE
1109
+ glu_Sphere(obj, arg1, arg2, arg3, arg4)
1110
+ VALUE obj, arg1, arg2, arg3, arg4;
1111
+ {
1112
+ struct quaddata* qdata;
1113
+ GLdouble radius;
1114
+ GLint slices;
1115
+ GLint stacks;
1116
+
1117
+ GetQUAD(arg1, qdata);
1118
+ radius = (GLdouble)NUM2DBL(arg2);
1119
+ slices = (GLint)NUM2INT(arg3);
1120
+ stacks = (GLint)NUM2INT(arg4);
1121
+
1122
+ gluSphere(qdata->qobj, radius, slices, stacks);
1123
+ return Qnil;
1124
+ }
1125
+ static VALUE
1126
+ glu_LookAt(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)
1127
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9;
1128
+ {
1129
+ GLdouble eyex;
1130
+ GLdouble eyey;
1131
+ GLdouble eyez;
1132
+ GLdouble centerx;
1133
+ GLdouble centery;
1134
+ GLdouble centerz;
1135
+ GLdouble upx;
1136
+ GLdouble upy;
1137
+ GLdouble upz;
1138
+ eyex = (GLdouble)NUM2DBL(arg1);
1139
+ eyey = (GLdouble)NUM2DBL(arg2);
1140
+ eyez = (GLdouble)NUM2DBL(arg3);
1141
+ centerx = (GLdouble)NUM2DBL(arg4);
1142
+ centery = (GLdouble)NUM2DBL(arg5);
1143
+ centerz = (GLdouble)NUM2DBL(arg6);
1144
+ upx = (GLdouble)NUM2DBL(arg7);
1145
+ upy = (GLdouble)NUM2DBL(arg8);
1146
+ upz = (GLdouble)NUM2DBL(arg9);
1147
+ gluLookAt( eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz );
1148
+ return Qnil;
1149
+ }
1150
+ static VALUE
1151
+ glu_Ortho2D(obj,arg1,arg2,arg3,arg4)
1152
+ VALUE obj,arg1,arg2,arg3,arg4;
1153
+ {
1154
+ GLdouble left;
1155
+ GLdouble right;
1156
+ GLdouble bottom;
1157
+ GLdouble top;
1158
+ left = (GLdouble)NUM2DBL(arg1);
1159
+ right = (GLdouble)NUM2DBL(arg2);
1160
+ bottom = (GLdouble)NUM2DBL(arg3);
1161
+ top = (GLdouble)NUM2DBL(arg4);
1162
+ gluOrtho2D(left,right,bottom,top);
1163
+ return Qnil;
1164
+ }
1165
+ static VALUE
1166
+ glu_Perspective(obj,arg1,arg2,arg3,arg4)
1167
+ VALUE obj,arg1,arg2,arg3,arg4;
1168
+ {
1169
+ GLdouble fovy;
1170
+ GLdouble aspect;
1171
+ GLdouble zNear;
1172
+ GLdouble zFar;
1173
+ fovy = (GLdouble)NUM2DBL(arg1);
1174
+ aspect = (GLdouble)NUM2DBL(arg2);
1175
+ zNear = (GLdouble)NUM2DBL(arg3);
1176
+ zFar = (GLdouble)NUM2DBL(arg4);
1177
+ gluPerspective(fovy,aspect,zNear,zFar);
1178
+ return Qnil;
1179
+ }
1180
+ static VALUE
1181
+ glu_PickMatrix(argc,argv,obj)
1182
+ int argc;
1183
+ VALUE* argv;
1184
+ VALUE obj;
1185
+ {
1186
+ GLdouble x;
1187
+ GLdouble y;
1188
+ GLdouble width;
1189
+ GLdouble height;
1190
+ GLint viewport[4];
1191
+
1192
+ VALUE args[5];
1193
+
1194
+ switch (rb_scan_args(argc, argv, "23", &args[0], &args[1], &args[2], &args[3], &args[4])) {
1195
+ case 2:
1196
+ width = 5.0f;
1197
+ height = 5.0f;
1198
+ glGetIntegerv(GL_VIEWPORT, viewport);
1199
+ break;
1200
+ case 4:
1201
+ width = (GLdouble)NUM2DBL(args[2]);
1202
+ height = (GLdouble)NUM2DBL(args[3]);
1203
+ glGetIntegerv(GL_VIEWPORT, viewport);
1204
+ break;
1205
+ case 5:
1206
+ width = (GLdouble)NUM2DBL(args[2]);
1207
+ height = (GLdouble)NUM2DBL(args[3]);
1208
+ ary2cint(args[4], viewport, 4);
1209
+ break;
1210
+ default:
1211
+ rb_raise(rb_eArgError, "GLU.PickMatrix args len:%d",argc);
1212
+ }
1213
+ x = (GLdouble)NUM2DBL(args[0]);
1214
+ y = (GLdouble)NUM2DBL(args[1]);
1215
+ gluPickMatrix(x, y, width, height, viewport);
1216
+ return Qnil;
1217
+ }
1218
+
1219
+ static VALUE
1220
+ glu_Project(argc,argv,obj)
1221
+ int argc;
1222
+ VALUE* argv;
1223
+ VALUE obj;
1224
+ {
1225
+ GLdouble ox;
1226
+ GLdouble oy;
1227
+ GLdouble oz;
1228
+ GLdouble mdl_mtx[4*4];
1229
+ GLdouble prj_mtx[4*4];
1230
+ GLint vport[4];
1231
+ GLdouble wx;
1232
+ GLdouble wy;
1233
+ GLdouble wz;
1234
+
1235
+ VALUE args[6];
1236
+ VALUE ret;
1237
+
1238
+ switch (rb_scan_args(argc, argv, "33", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5])) {
1239
+ case 3:
1240
+ glGetDoublev(GL_MODELVIEW_MATRIX, mdl_mtx);
1241
+ glGetDoublev(GL_PROJECTION_MATRIX, prj_mtx);
1242
+ glGetIntegerv(GL_VIEWPORT, vport);
1243
+ break;
1244
+ case 6:
1245
+ ary2cmat4x4dbl(args[3], mdl_mtx);
1246
+ ary2cmat4x4dbl(args[4], prj_mtx);
1247
+ ary2cint(args[5], vport, 4);
1248
+ break;
1249
+ default:
1250
+ rb_raise(rb_eArgError, "GLU.Project args len:%d",argc);
1251
+ }
1252
+ ox = (GLdouble)NUM2DBL(args[0]);
1253
+ oy = (GLdouble)NUM2DBL(args[1]);
1254
+ oz = (GLdouble)NUM2DBL(args[2]);
1255
+
1256
+ if (gluProject(ox, oy, oz, mdl_mtx, prj_mtx, vport, &wx, &wy, &wz)
1257
+ == GL_TRUE) {
1258
+ ret = rb_ary_new3(3, rb_float_new(wx), rb_float_new(wy), rb_float_new(wz));
1259
+ return ret;
1260
+ }
1261
+ else
1262
+ return Qnil;
1263
+ }
1264
+ static VALUE
1265
+ glu_UnProject(argc,argv,obj)
1266
+ int argc;
1267
+ VALUE* argv;
1268
+ VALUE obj;
1269
+ {
1270
+ GLdouble wx;
1271
+ GLdouble wy;
1272
+ GLdouble wz;
1273
+ GLdouble mdl_mtx[4*4];
1274
+ GLdouble prj_mtx[4*4];
1275
+ GLint vport[4];
1276
+ GLdouble ox;
1277
+ GLdouble oy;
1278
+ GLdouble oz;
1279
+
1280
+ VALUE args[6];
1281
+ VALUE ret;
1282
+
1283
+ switch (rb_scan_args(argc, argv, "33", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5])) {
1284
+ case 3:
1285
+ glGetDoublev(GL_MODELVIEW_MATRIX, mdl_mtx);
1286
+ glGetDoublev(GL_PROJECTION_MATRIX, prj_mtx);
1287
+ glGetIntegerv(GL_VIEWPORT, vport);
1288
+ break;
1289
+ case 6:
1290
+ ary2cmat4x4dbl(args[3], mdl_mtx);
1291
+ ary2cmat4x4dbl(args[4], prj_mtx);
1292
+ ary2cint(args[5], vport, 4);
1293
+ break;
1294
+ default:
1295
+ rb_raise(rb_eArgError, "GLU.UnProject args len:%d",argc);
1296
+ }
1297
+ wx = (GLdouble)NUM2DBL(args[0]);
1298
+ wy = (GLdouble)NUM2DBL(args[1]);
1299
+ wz = (GLdouble)NUM2DBL(args[2]);
1300
+
1301
+ if (gluUnProject(wx, wy, wz, mdl_mtx, prj_mtx, vport, &ox, &oy, &oz)
1302
+ == GL_TRUE) {
1303
+ ret = rb_ary_new3(3, rb_float_new(ox), rb_float_new(oy), rb_float_new(oz));
1304
+ return ret;
1305
+ }
1306
+ else
1307
+ return Qnil;
1308
+ }
1309
+
1310
+ static VALUE
1311
+ glu_Build2DMipmaps(obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
1312
+ VALUE obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7;
1313
+ {
1314
+ GLenum target;
1315
+ GLint components;
1316
+ GLint width;
1317
+ GLint height;
1318
+ GLenum format;
1319
+ GLenum type;
1320
+ void* data;
1321
+
1322
+ int type_size;
1323
+ int format_size;
1324
+ int size;
1325
+
1326
+ target = (GLenum)NUM2INT(arg1);
1327
+ components = (GLint)NUM2INT(arg2);
1328
+ width = (GLint)NUM2INT(arg3);
1329
+ height = (GLint)NUM2INT(arg4);
1330
+ format = (GLenum)NUM2INT(arg5);
1331
+ type = (GLenum)NUM2INT(arg6);
1332
+ if (TYPE(arg7) == T_STRING) {
1333
+ type_size = gltype_size(type) / 8;
1334
+ format_size = glformat_size(format);
1335
+ if (type_size == -1 || format_size == -1)
1336
+ return Qnil;
1337
+ size = type_size*format_size*height*width;
1338
+ if (RSTRING(arg7)->len < size)
1339
+ rb_raise(rb_eArgError, "string length:%d",RSTRING(arg7)->len);
1340
+ data = RSTRING(arg7)->ptr;
1341
+ } else
1342
+ rb_raise(rb_eTypeError, "type mismatch:%s",rb_class2name(arg7));
1343
+ return INT2NUM(gluBuild2DMipmaps(target, components, width, height, format, type, data));
1344
+ }
1345
+
1346
+ static VALUE
1347
+ glu_ScaleImage(obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
1348
+ VALUE obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8;
1349
+ {
1350
+ GLenum format;
1351
+ GLint widthin;
1352
+ GLint heightin;
1353
+ GLenum typein;
1354
+ void* datain;
1355
+ GLint widthout;
1356
+ GLint heightout;
1357
+ GLenum typeout;
1358
+ int type_size;
1359
+ int format_size;
1360
+ int size;
1361
+ VALUE ret;
1362
+
1363
+ format = (GLenum)NUM2INT(arg1);
1364
+ widthin = (GLint)NUM2INT(arg2);
1365
+ heightin = (GLint)NUM2INT(arg3);
1366
+ typein = (GLenum)NUM2INT(arg4);
1367
+ if (TYPE(arg5) == T_STRING) {
1368
+ type_size = gltype_size(typein) / 8;
1369
+ format_size = glformat_size(format);
1370
+ if (type_size == -1 || format_size == -1)
1371
+ return Qnil;
1372
+ size = type_size*format_size*heightin*widthin;
1373
+ if (RSTRING(arg5)->len < size)
1374
+ rb_raise(rb_eArgError, "string length:%d",RSTRING(arg5)->len);
1375
+ datain = RSTRING(arg5)->ptr;
1376
+ } else
1377
+ rb_raise(rb_eTypeError, "type mismatch:%s",rb_class2name(arg5));
1378
+
1379
+ widthout = (GLint)NUM2INT(arg6);
1380
+ heightout = (GLint)NUM2INT(arg7);
1381
+ typeout = (GLenum)NUM2INT(arg8);
1382
+ type_size = gltype_size(typeout) / 8;
1383
+ ret = allocate_buffer_with_string(widthout*heightout*format_size*type_size);
1384
+ gluScaleImage(format, widthin, heightin, typein, datain,
1385
+ widthout, heightout, typeout, (GLvoid*)RSTRING(ret)->ptr);
1386
+ return ret;
1387
+ }
1388
+
1389
+ static VALUE
1390
+ glu_ErrorString(obj, arg1)
1391
+ VALUE obj, arg1;
1392
+ {
1393
+ GLenum errorCode;
1394
+ GLubyte* error;
1395
+ errorCode = (GLenum)NUM2INT(arg1);
1396
+ error = (GLubyte*)gluErrorString(errorCode);
1397
+ if (error)
1398
+ return rb_str_new2(error);
1399
+ else
1400
+ return Qnil;
1401
+ }
1402
+ #if defined(GLU_VERSION_1_1)
1403
+ static VALUE
1404
+ glu_GetString(obj, arg1)
1405
+ VALUE obj, arg1;
1406
+ {
1407
+ GLenum name;
1408
+ GLubyte* str;
1409
+ name = (GLenum)NUM2INT(arg1);
1410
+ str = (GLubyte*)gluGetString(name);
1411
+ if (str)
1412
+ return rb_str_new2(str);
1413
+ else
1414
+ return Qnil;
1415
+ }
1416
+ #endif
1417
+
1418
+ static VALUE module;
1419
+
1420
+ #ifndef GLU_BEGIN
1421
+ #define GLU_BEGIN 100100
1422
+ #endif
1423
+ #ifndef GLU_VERTEX
1424
+ #define GLU_VERTEX 100101
1425
+ #endif
1426
+ #ifndef GLU_END
1427
+ #define GLU_END 100102
1428
+ #endif
1429
+ #ifndef GLU_EDGE_FLAG
1430
+ #define GLU_EDGE_FLAG 100104
1431
+ #endif
1432
+ #ifndef GLU_CW
1433
+ #define GLU_CW 100120
1434
+ #endif
1435
+ #ifndef GLU_CCW
1436
+ #define GLU_CCW 100121
1437
+ #endif
1438
+ #ifndef GLU_INTERIOR
1439
+ #define GLU_INTERIOR 100122
1440
+ #endif
1441
+ #ifndef GLU_EXTERIOR
1442
+ #define GLU_EXTERIOR 100123
1443
+ #endif
1444
+ #ifndef GLU_UNKNOWN
1445
+ #define GLU_UNKNOWN 100124
1446
+ #endif
1447
+ #ifndef GLU_ERROR
1448
+ #define GLU_ERROR 100103
1449
+ #endif
1450
+
1451
+
1452
+ void Init_glu()
1453
+ {
1454
+ callId = rb_intern("call");
1455
+ refId = rb_intern("[]");
1456
+ module = rb_define_module("GLU");
1457
+ rb_define_module_function(module, "gluNewNurbsRenderer", glu_NewNurbsRenderer, 0);
1458
+ rb_define_module_function(module, "gluDeleteNurbsRenderer", glu_DeleteNurbsRenderer, 1);
1459
+ rb_define_module_function(module, "gluNurbsProperty", glu_NurbsProperty, 3);
1460
+ rb_define_module_function(module, "gluGetNurbsProperty", glu_GetNurbsProperty, 2);
1461
+ rb_define_module_function(module, "gluBeginCurve", glu_BeginCurve, 1);
1462
+ rb_define_module_function(module, "gluEndCurve", glu_EndCurve, 1);
1463
+ rb_define_module_function(module, "gluNurbsCurve", glu_NurbsCurve, -1);
1464
+ rb_define_module_function(module, "gluBeginSurface", glu_BeginSurface, 1);
1465
+ rb_define_module_function(module, "gluEndSurface", glu_EndSurface, 1);
1466
+ rb_define_module_function(module, "gluNurbsSurface", glu_NurbsSurface, -1);
1467
+ rb_define_module_function(module, "gluBeginTrim", glu_BeginTrim, 1);
1468
+ rb_define_module_function(module, "gluEndTrim", glu_EndTrim, 1);
1469
+ rb_define_module_function(module, "gluPwlCurve", glu_PwlCurve, -1);
1470
+ rb_define_module_function(module, "gluNewTess", glu_NewTess, 0);
1471
+ rb_define_module_function(module, "gluDeleteTess", glu_DeleteTess, 1);
1472
+ rb_define_module_function(module, "gluTessCallback", glu_TessCallback, 3);
1473
+ rb_define_module_function(module, "gluBeginPolygon", glu_BeginPolygon, 1);
1474
+ rb_define_module_function(module, "gluTessVertex", glu_TessVertex, 3);
1475
+ rb_define_module_function(module, "gluNextContour", glu_NextContour, 2);
1476
+ rb_define_module_function(module, "gluEndPolygon", glu_EndPolygon, 1);
1477
+ #if defined(GLU_VERSION_1_2)
1478
+ rb_define_module_function(module, "gluTessBeginPolygon", glu_TessBeginPolygon, 2);
1479
+ rb_define_module_function(module, "gluTessBeginContour", glu_TessBeginContour, 1);
1480
+ rb_define_module_function(module, "gluTessEndContour", glu_TessEndContour, 1);
1481
+ rb_define_module_function(module, "gluTessEndPolygon", glu_TessEndPolygon, 1);
1482
+ rb_define_module_function(module, "gluTessProperty", glu_TessProperty, 3);
1483
+ rb_define_module_function(module, "gluTessNormal", glu_TessNormal, 4);
1484
+ rb_define_module_function(module, "gluGetTessProperty", glu_GetTessProperty, 2);
1485
+ #endif /* GLU_VERSION_1_2 */
1486
+ rb_define_module_function(module, "gluNewQuadric", glu_NewQuadric, 0);
1487
+ rb_define_module_function(module, "gluDeleteQuadric", glu_DeleteQuadric, 1);
1488
+ rb_define_module_function(module, "gluQuadricNormals", glu_QuadricNormals, 2);
1489
+ rb_define_module_function(module, "gluQuadricTexture", glu_QuadricTexture, 2);
1490
+ rb_define_module_function(module, "gluQuadricOrientation", glu_QuadricOrientation, 2);
1491
+ rb_define_module_function(module, "gluQuadricDrawStyle", glu_QuadricDrawStyle, 2);
1492
+ rb_define_module_function(module, "gluCylinder", glu_Cylinder, 6);
1493
+ rb_define_module_function(module, "gluDisk", glu_Disk, 5);
1494
+ rb_define_module_function(module, "gluPartialDisk", glu_PartialDisk, 7);
1495
+ rb_define_module_function(module, "gluSphere", glu_Sphere, 4);
1496
+
1497
+ rb_define_module_function(module, "gluLookAt", glu_LookAt, 9);
1498
+ rb_define_module_function(module, "gluOrtho2D", glu_Ortho2D, 4);
1499
+ rb_define_module_function(module, "gluPerspective", glu_Perspective, 4);
1500
+ rb_define_module_function(module, "gluPickMatrix", glu_PickMatrix, -1);
1501
+ rb_define_module_function(module, "gluProject", glu_Project, -1);
1502
+ rb_define_module_function(module, "gluUnProject", glu_UnProject, -1);
1503
+ rb_define_module_function(module, "gluBuild2DMipmaps", glu_Build2DMipmaps, 7);
1504
+ rb_define_module_function(module, "gluScaleImage", glu_ScaleImage, 8);
1505
+ rb_define_module_function(module, "gluErrorString", glu_ErrorString, 1);
1506
+ #if defined(GLU_VERSION_1_1)
1507
+ rb_define_module_function(module, "gluGetString", glu_GetString, 1);
1508
+ #endif
1509
+
1510
+ rb_define_const(module, "GLU_SMOOTH", INT2NUM(GLU_SMOOTH));
1511
+ rb_define_const(module, "GLU_FLAT", INT2NUM(GLU_FLAT));
1512
+ rb_define_const(module, "GLU_NONE", INT2NUM(GLU_NONE));
1513
+ rb_define_const(module, "GLU_POINT", INT2NUM(GLU_POINT));
1514
+ rb_define_const(module, "GLU_LINE", INT2NUM(GLU_LINE));
1515
+ rb_define_const(module, "GLU_FILL", INT2NUM(GLU_FILL));
1516
+ rb_define_const(module, "GLU_SILHOUETTE", INT2NUM(GLU_SILHOUETTE));
1517
+ rb_define_const(module, "GLU_OUTSIDE", INT2NUM(GLU_OUTSIDE));
1518
+ rb_define_const(module, "GLU_INSIDE", INT2NUM(GLU_INSIDE));
1519
+ #if defined(GLU_VERSION_1_2)
1520
+ rb_define_const(module, "GLU_TESS_BEGIN", INT2NUM(GLU_TESS_BEGIN));
1521
+ rb_define_const(module, "GLU_TESS_VERTEX", INT2NUM(GLU_TESS_VERTEX));
1522
+ rb_define_const(module, "GLU_TESS_END", INT2NUM(GLU_TESS_END));
1523
+ rb_define_const(module, "GLU_TESS_ERROR", INT2NUM(GLU_TESS_ERROR));
1524
+ rb_define_const(module, "GLU_TESS_EDGE_FLAG", INT2NUM(GLU_TESS_EDGE_FLAG));
1525
+ rb_define_const(module, "GLU_TESS_COMBINE", INT2NUM(GLU_TESS_COMBINE));
1526
+
1527
+ rb_define_const(module, "GLU_TESS_BEGIN_DATA", INT2NUM(GLU_TESS_BEGIN_DATA));
1528
+ rb_define_const(module, "GLU_TESS_VERTEX_DATA", INT2NUM(GLU_TESS_VERTEX_DATA));
1529
+ rb_define_const(module, "GLU_TESS_END_DATA", INT2NUM(GLU_TESS_END_DATA));
1530
+ rb_define_const(module, "GLU_TESS_ERROR_DATA", INT2NUM(GLU_TESS_ERROR_DATA));
1531
+ rb_define_const(module, "GLU_TESS_EDGE_FLAG_DATA", INT2NUM(GLU_TESS_EDGE_FLAG_DATA));
1532
+ rb_define_const(module, "GLU_TESS_COMBINE_DATA", INT2NUM(GLU_TESS_COMBINE_DATA));
1533
+
1534
+ /* Winding rules */
1535
+ rb_define_const(module, "GLU_TESS_WINDING_ODD", INT2NUM(GLU_TESS_WINDING_ODD));
1536
+ rb_define_const(module, "GLU_TESS_WINDING_NONZERO", INT2NUM(GLU_TESS_WINDING_NONZERO));
1537
+ rb_define_const(module, "GLU_TESS_WINDING_POSITIVE", INT2NUM(GLU_TESS_WINDING_POSITIVE));
1538
+ rb_define_const(module, "GLU_TESS_WINDING_NEGATIVE", INT2NUM(GLU_TESS_WINDING_NEGATIVE));
1539
+ rb_define_const(module, "GLU_TESS_WINDING_ABS_GEQ_TWO", INT2NUM(GLU_TESS_WINDING_ABS_GEQ_TWO));
1540
+
1541
+ /* Tessellation properties */
1542
+ rb_define_const(module, "GLU_TESS_WINDING_RULE", INT2NUM(GLU_TESS_WINDING_RULE));
1543
+ rb_define_const(module, "GLU_TESS_BOUNDARY_ONLY", INT2NUM(GLU_TESS_BOUNDARY_ONLY));
1544
+ rb_define_const(module, "GLU_TESS_TOLERANCE", INT2NUM(GLU_TESS_TOLERANCE));
1545
+ #endif /* GLU_VERSION_1_2 */
1546
+
1547
+ rb_define_const(module, "GLU_BEGIN", INT2NUM(GLU_BEGIN));
1548
+ rb_define_const(module, "GLU_VERTEX", INT2NUM(GLU_VERTEX));
1549
+ rb_define_const(module, "GLU_END", INT2NUM(GLU_END));
1550
+ rb_define_const(module, "GLU_ERROR", INT2NUM(GLU_ERROR));
1551
+ rb_define_const(module, "GLU_EDGE_FLAG", INT2NUM(GLU_EDGE_FLAG));
1552
+ rb_define_const(module, "GLU_CW", INT2NUM(GLU_CW));
1553
+ rb_define_const(module, "GLU_CCW", INT2NUM(GLU_CCW));
1554
+ rb_define_const(module, "GLU_INTERIOR", INT2NUM(GLU_INTERIOR));
1555
+ rb_define_const(module, "GLU_EXTERIOR", INT2NUM(GLU_EXTERIOR));
1556
+ rb_define_const(module, "GLU_UNKNOWN", INT2NUM(GLU_UNKNOWN));
1557
+ rb_define_const(module, "GLU_TESS_ERROR1", INT2NUM(GLU_TESS_ERROR1));
1558
+ rb_define_const(module, "GLU_TESS_ERROR2", INT2NUM(GLU_TESS_ERROR2));
1559
+ rb_define_const(module, "GLU_TESS_ERROR3", INT2NUM(GLU_TESS_ERROR3));
1560
+ rb_define_const(module, "GLU_TESS_ERROR4", INT2NUM(GLU_TESS_ERROR4));
1561
+ rb_define_const(module, "GLU_TESS_ERROR5", INT2NUM(GLU_TESS_ERROR5));
1562
+ rb_define_const(module, "GLU_TESS_ERROR6", INT2NUM(GLU_TESS_ERROR6));
1563
+ rb_define_const(module, "GLU_TESS_ERROR7", INT2NUM(GLU_TESS_ERROR7));
1564
+ rb_define_const(module, "GLU_TESS_ERROR8", INT2NUM(GLU_TESS_ERROR8));
1565
+ #if defined(TESS_ERROR9)
1566
+ rb_define_const(module, "GLU_TESS_ERROR9", INT2NUM(GLU_TESS_ERROR9));
1567
+ #endif
1568
+ #if defined(GLU_VERSION_1_3)
1569
+ rb_define_const(module, "GLU_AUTO_LOAD_MATRIX", INT2NUM(GLU_AUTO_LOAD_MATRIX));
1570
+ rb_define_const(module, "GLU_CULLING", INT2NUM(GLU_CULLING));
1571
+ rb_define_const(module, "GLU_SAMPLING_TOLERANCE", INT2NUM(GLU_SAMPLING_TOLERANCE));
1572
+ rb_define_const(module, "GLU_DISPLAY_MODE", INT2NUM(GLU_DISPLAY_MODE));
1573
+ rb_define_const(module, "GLU_SAMPLING_METHOD", INT2NUM(GLU_SAMPLING_METHOD));
1574
+ rb_define_const(module, "GLU_U_STEP", INT2NUM(GLU_U_STEP));
1575
+ rb_define_const(module, "GLU_V_STEP", INT2NUM(GLU_V_STEP));
1576
+ #endif
1577
+ rb_define_const(module, "GLU_PATH_LENGTH", INT2NUM(GLU_PATH_LENGTH));
1578
+ rb_define_const(module, "GLU_PARAMETRIC_ERROR", INT2NUM(GLU_PARAMETRIC_ERROR));
1579
+ rb_define_const(module, "GLU_DOMAIN_DISTANCE", INT2NUM(GLU_DOMAIN_DISTANCE));
1580
+ rb_define_const(module, "GLU_MAP1_TRIM_2", INT2NUM(GLU_MAP1_TRIM_2));
1581
+ rb_define_const(module, "GLU_MAP1_TRIM_3", INT2NUM(GLU_MAP1_TRIM_3));
1582
+ rb_define_const(module, "GLU_OUTLINE_POLYGON", INT2NUM(GLU_OUTLINE_POLYGON));
1583
+ rb_define_const(module, "GLU_OUTLINE_PATCH", INT2NUM(GLU_OUTLINE_PATCH));
1584
+ rb_define_const(module, "GLU_NURBS_ERROR1", INT2NUM(GLU_NURBS_ERROR1));
1585
+ rb_define_const(module, "GLU_NURBS_ERROR2", INT2NUM(GLU_NURBS_ERROR2));
1586
+ rb_define_const(module, "GLU_NURBS_ERROR3", INT2NUM(GLU_NURBS_ERROR3));
1587
+ rb_define_const(module, "GLU_NURBS_ERROR4", INT2NUM(GLU_NURBS_ERROR4));
1588
+ rb_define_const(module, "GLU_NURBS_ERROR5", INT2NUM(GLU_NURBS_ERROR5));
1589
+ rb_define_const(module, "GLU_NURBS_ERROR6", INT2NUM(GLU_NURBS_ERROR6));
1590
+ rb_define_const(module, "GLU_NURBS_ERROR7", INT2NUM(GLU_NURBS_ERROR7));
1591
+ rb_define_const(module, "GLU_NURBS_ERROR8", INT2NUM(GLU_NURBS_ERROR8));
1592
+ rb_define_const(module, "GLU_NURBS_ERROR9", INT2NUM(GLU_NURBS_ERROR9));
1593
+ rb_define_const(module, "GLU_NURBS_ERROR10", INT2NUM(GLU_NURBS_ERROR10));
1594
+ rb_define_const(module, "GLU_NURBS_ERROR11", INT2NUM(GLU_NURBS_ERROR11));
1595
+ rb_define_const(module, "GLU_NURBS_ERROR12", INT2NUM(GLU_NURBS_ERROR12));
1596
+ rb_define_const(module, "GLU_NURBS_ERROR13", INT2NUM(GLU_NURBS_ERROR13));
1597
+ rb_define_const(module, "GLU_NURBS_ERROR14", INT2NUM(GLU_NURBS_ERROR14));
1598
+ rb_define_const(module, "GLU_NURBS_ERROR15", INT2NUM(GLU_NURBS_ERROR15));
1599
+ rb_define_const(module, "GLU_NURBS_ERROR16", INT2NUM(GLU_NURBS_ERROR16));
1600
+ rb_define_const(module, "GLU_NURBS_ERROR17", INT2NUM(GLU_NURBS_ERROR17));
1601
+ rb_define_const(module, "GLU_NURBS_ERROR18", INT2NUM(GLU_NURBS_ERROR18));
1602
+ rb_define_const(module, "GLU_NURBS_ERROR19", INT2NUM(GLU_NURBS_ERROR19));
1603
+ rb_define_const(module, "GLU_NURBS_ERROR20", INT2NUM(GLU_NURBS_ERROR20));
1604
+ rb_define_const(module, "GLU_NURBS_ERROR21", INT2NUM(GLU_NURBS_ERROR21));
1605
+ rb_define_const(module, "GLU_NURBS_ERROR22", INT2NUM(GLU_NURBS_ERROR22));
1606
+ rb_define_const(module, "GLU_NURBS_ERROR23", INT2NUM(GLU_NURBS_ERROR23));
1607
+ rb_define_const(module, "GLU_NURBS_ERROR24", INT2NUM(GLU_NURBS_ERROR24));
1608
+ rb_define_const(module, "GLU_NURBS_ERROR25", INT2NUM(GLU_NURBS_ERROR25));
1609
+ rb_define_const(module, "GLU_NURBS_ERROR26", INT2NUM(GLU_NURBS_ERROR26));
1610
+ rb_define_const(module, "GLU_NURBS_ERROR27", INT2NUM(GLU_NURBS_ERROR27));
1611
+ rb_define_const(module, "GLU_NURBS_ERROR28", INT2NUM(GLU_NURBS_ERROR28));
1612
+ rb_define_const(module, "GLU_NURBS_ERROR29", INT2NUM(GLU_NURBS_ERROR29));
1613
+ rb_define_const(module, "GLU_NURBS_ERROR30", INT2NUM(GLU_NURBS_ERROR30));
1614
+ rb_define_const(module, "GLU_NURBS_ERROR31", INT2NUM(GLU_NURBS_ERROR31));
1615
+ rb_define_const(module, "GLU_NURBS_ERROR32", INT2NUM(GLU_NURBS_ERROR32));
1616
+ rb_define_const(module, "GLU_NURBS_ERROR33", INT2NUM(GLU_NURBS_ERROR33));
1617
+ rb_define_const(module, "GLU_NURBS_ERROR34", INT2NUM(GLU_NURBS_ERROR34));
1618
+ rb_define_const(module, "GLU_NURBS_ERROR35", INT2NUM(GLU_NURBS_ERROR35));
1619
+ rb_define_const(module, "GLU_NURBS_ERROR36", INT2NUM(GLU_NURBS_ERROR36));
1620
+ rb_define_const(module, "GLU_NURBS_ERROR37", INT2NUM(GLU_NURBS_ERROR37));
1621
+ rb_define_const(module, "GLU_INVALID_ENUM", INT2NUM(GLU_INVALID_ENUM));
1622
+ rb_define_const(module, "GLU_INVALID_VALUE", INT2NUM(GLU_INVALID_VALUE));
1623
+ rb_define_const(module, "GLU_OUT_OF_MEMORY", INT2NUM(GLU_OUT_OF_MEMORY));
1624
+ #ifdef GLU_INCOMPATIBLE_GL_VERSION
1625
+ rb_define_const(module, "GLU_INCOMPATIBLE_GL_VERSION", INT2NUM(GLU_INCOMPATIBLE_GL_VERSION));
1626
+ #endif
1627
+ rb_define_const(module, "GLU_VERSION", INT2NUM(GLU_VERSION));
1628
+ rb_define_const(module, "GLU_EXTENSIONS", INT2NUM(GLU_EXTENSIONS));
1629
+
1630
+ cNurbs = rb_define_class("Nurbs", rb_cObject);
1631
+ cTess = rb_define_class("Tess", rb_cObject);
1632
+ cQuad = rb_define_class("Quadric", rb_cObject);
1633
+
1634
+ rb_global_variable(&t_current);
1635
+ t_current = rb_ary_new();
1636
+ }