glu 8.1.0 → 8.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.travis.yml +15 -0
- data/History.rdoc +7 -2
- data/Manifest.txt +4 -1
- data/Rakefile +2 -1
- data/ext/glu/common.h +17 -8
- data/ext/glu/conv.h +0 -2
- data/ext/glu/extconf.rb +8 -5
- data/ext/glu/gl-enums.h +14588 -0
- data/ext/glu/glu.c +975 -971
- data/lib/glu.rb +8 -5
- data/test/dummy.xorg.conf +131 -0
- metadata +34 -9
- metadata.gz.sig +0 -0
data/ext/glu/glu.c
CHANGED
|
@@ -33,24 +33,24 @@ typedef GLUtesselator tesselatorObj;
|
|
|
33
33
|
and free them after that call */
|
|
34
34
|
|
|
35
35
|
struct glu_MesaStack {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
int len;
|
|
37
|
+
GLfloat **ptr;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
static struct glu_MesaStack gms = {0, NULL};
|
|
41
41
|
|
|
42
42
|
struct nurbsdata {
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
GLUnurbsObj *nobj;
|
|
44
|
+
VALUE n_ref;
|
|
45
45
|
};
|
|
46
46
|
struct tessdata {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
tesselatorObj *tobj;
|
|
48
|
+
VALUE t_ref;
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
struct quaddata {
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
GLUquadricObj *qobj;
|
|
53
|
+
VALUE q_ref;
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
static VALUE cNurbs;
|
|
@@ -60,156 +60,156 @@ static VALUE cQuad;
|
|
|
60
60
|
#define REF_LAST 15
|
|
61
61
|
|
|
62
62
|
#define GetNURBS(obj, ndata) {\
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
Data_Get_Struct(obj, struct nurbsdata, ndata);\
|
|
64
|
+
if (ndata->nobj == NULL) rb_raise(rb_eRuntimeError, "Nurbs Object already deleted!");\
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
#define GetTESS(obj, tdata) {\
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
Data_Get_Struct(obj, struct tessdata, tdata);\
|
|
69
|
+
if (tdata->tobj == NULL) rb_raise(rb_eRuntimeError, "Triangulator Object already deleted!");\
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
#define GetQUAD(obj, qdata) {\
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
Data_Get_Struct(obj, struct quaddata, qdata);\
|
|
74
|
+
if (qdata->qobj == NULL) rb_raise(rb_eRuntimeError, "Quadric Object already deleted!");\
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
static ID callId;
|
|
78
78
|
static ID refId;
|
|
79
79
|
|
|
80
80
|
/*
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
* GLU Implementation
|
|
82
|
+
*/
|
|
83
83
|
|
|
84
84
|
/*
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
* Nurbs
|
|
86
|
+
*/
|
|
87
87
|
/* from nurbscrv.c */
|
|
88
88
|
static int
|
|
89
89
|
get_curve_dim(type)
|
|
90
90
|
GLenum type;
|
|
91
91
|
{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
92
|
+
switch(type)
|
|
93
|
+
{
|
|
94
|
+
case GL_MAP1_VERTEX_3: return 3;
|
|
95
|
+
case GL_MAP1_VERTEX_4: return 4;
|
|
96
|
+
case GL_MAP1_INDEX: return 1;
|
|
97
|
+
case GL_MAP1_COLOR_4: return 4;
|
|
98
|
+
case GL_MAP1_NORMAL: return 3;
|
|
99
|
+
case GL_MAP1_TEXTURE_COORD_1: return 1;
|
|
100
|
+
case GL_MAP1_TEXTURE_COORD_2: return 2;
|
|
101
|
+
case GL_MAP1_TEXTURE_COORD_3: return 3;
|
|
102
|
+
case GL_MAP1_TEXTURE_COORD_4: return 4;
|
|
103
|
+
default:
|
|
104
|
+
rb_raise(rb_eArgError,"Unknown curve type '%i'",type);
|
|
105
|
+
}
|
|
106
|
+
return 0; /* never gets here */
|
|
107
107
|
}
|
|
108
108
|
/* from nurbssrf.c */
|
|
109
109
|
static int
|
|
110
110
|
get_surface_dim(GLenum type)
|
|
111
111
|
{
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
112
|
+
switch(type)
|
|
113
|
+
{
|
|
114
|
+
case GL_MAP2_VERTEX_3: return 3;
|
|
115
|
+
case GL_MAP2_VERTEX_4: return 4;
|
|
116
|
+
case GL_MAP2_INDEX: return 1;
|
|
117
|
+
case GL_MAP2_COLOR_4: return 4;
|
|
118
|
+
case GL_MAP2_NORMAL: return 3;
|
|
119
|
+
case GL_MAP2_TEXTURE_COORD_1: return 1;
|
|
120
|
+
case GL_MAP2_TEXTURE_COORD_2: return 2;
|
|
121
|
+
case GL_MAP2_TEXTURE_COORD_3: return 3;
|
|
122
|
+
case GL_MAP2_TEXTURE_COORD_4: return 4;
|
|
123
|
+
default:
|
|
124
|
+
rb_raise(rb_eArgError,"Unknown surface type '%i'",type);
|
|
125
|
+
}
|
|
126
|
+
return 0; /* never gets here */
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
VALUE GLUError_initialize(VALUE obj,VALUE message, VALUE error_id)
|
|
130
130
|
{
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
rb_call_super(1, &message);
|
|
132
|
+
rb_iv_set(obj, "@id", error_id);
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
return obj;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
void check_for_gluerror(GLenum error)
|
|
138
138
|
{
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
139
|
+
const char *error_string;
|
|
140
|
+
VALUE exc;
|
|
141
|
+
|
|
142
|
+
/* no error */
|
|
143
|
+
if (error==0)
|
|
144
|
+
return;
|
|
145
|
+
|
|
146
|
+
switch(error) {
|
|
147
|
+
case GLU_INVALID_ENUM: error_string = "invalid enumerant"; break;
|
|
148
|
+
case GLU_INVALID_VALUE: error_string = "invalid value"; break;
|
|
149
|
+
case GLU_INVALID_OPERATION: error_string = "invalid operation"; break;
|
|
150
|
+
case GLU_OUT_OF_MEMORY: error_string = "out of memory"; break;
|
|
151
|
+
default: error_string = "unknown error"; break;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
exc = rb_funcall(Class_GLUError, rb_intern("new"), 2, rb_str_new2(error_string), UINT2NUM(error));
|
|
155
|
+
rb_funcall(rb_cObject, rb_intern("raise"), 1, exc);
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
/*
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
* NURBS API
|
|
160
|
+
*/
|
|
161
161
|
static VALUE n_current;
|
|
162
162
|
|
|
163
163
|
static void
|
|
164
164
|
free_nurbs(ndata)
|
|
165
165
|
struct nurbsdata *ndata;
|
|
166
166
|
{
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
if (ndata->nobj) gluDeleteNurbsRenderer(ndata->nobj);
|
|
168
|
+
ndata->nobj = NULL;
|
|
169
|
+
ndata->n_ref = Qnil;
|
|
170
170
|
}
|
|
171
171
|
static void
|
|
172
172
|
mark_nurbs(ndata)
|
|
173
173
|
struct nurbsdata* ndata;
|
|
174
174
|
{
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
if (ndata->nobj)
|
|
176
|
+
rb_gc_mark(ndata->n_ref);
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
static void CALLBACK
|
|
180
180
|
n_error(errorno)
|
|
181
181
|
GLenum errorno;
|
|
182
182
|
{
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
183
|
+
VALUE nurbs;
|
|
184
|
+
struct nurbsdata *ndata;
|
|
185
|
+
nurbs = rb_ary_entry(n_current, -1);
|
|
186
|
+
if (nurbs == Qnil)
|
|
187
|
+
return;
|
|
188
|
+
GetNURBS(nurbs, ndata);
|
|
189
|
+
rb_funcall(rb_ary_entry(ndata->n_ref, GLU_ERROR), callId, 1, INT2NUM(errorno));
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
static VALUE
|
|
193
193
|
glu_NurbsCallback(obj, arg1, arg2, arg3)
|
|
194
194
|
VALUE obj, arg1, arg2, arg3;
|
|
195
195
|
{
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
196
|
+
struct nurbsdata* ndata;
|
|
197
|
+
GLenum type;
|
|
198
|
+
GetNURBS(arg1, ndata);
|
|
199
|
+
type = (GLenum)NUM2INT(arg2);
|
|
200
|
+
if (!rb_obj_is_kind_of(arg3,rb_cProc) && !NIL_P(arg3))
|
|
201
|
+
rb_raise(rb_eTypeError, "gluNurbsCallback needs Proc Object:%s",rb_class2name(CLASS_OF(arg3)));
|
|
202
202
|
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
if (type!=GLU_ERROR)
|
|
204
|
+
return Qnil;
|
|
205
205
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
206
|
+
rb_ary_store(ndata->n_ref, type, arg3);
|
|
207
|
+
if (NIL_P(arg3))
|
|
208
|
+
gluNurbsCallback(ndata->nobj, type, NULL);
|
|
209
|
+
else
|
|
210
|
+
gluNurbsCallback(ndata->nobj, type, n_error);
|
|
211
211
|
|
|
212
|
-
|
|
212
|
+
return Qnil;
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
|
|
@@ -217,79 +217,79 @@ static VALUE
|
|
|
217
217
|
glu_NewNurbsRenderer(obj)
|
|
218
218
|
VALUE obj;
|
|
219
219
|
{
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
220
|
+
VALUE ret;
|
|
221
|
+
struct nurbsdata *ndata;
|
|
222
|
+
ret = Data_Make_Struct(cNurbs, struct nurbsdata, mark_nurbs, free_nurbs, ndata);
|
|
223
|
+
ndata->nobj = gluNewNurbsRenderer();
|
|
224
|
+
ndata->n_ref = rb_ary_new2(REF_LAST);
|
|
225
|
+
|
|
226
|
+
return ret;
|
|
227
227
|
}
|
|
228
228
|
static VALUE
|
|
229
229
|
glu_DeleteNurbsRenderer(obj, arg1)
|
|
230
230
|
VALUE obj, arg1;
|
|
231
231
|
{
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
232
|
+
struct nurbsdata *ndata;
|
|
233
|
+
GetNURBS(arg1, ndata);
|
|
234
|
+
free_nurbs(ndata);
|
|
235
|
+
|
|
236
|
+
return Qnil;
|
|
237
237
|
}
|
|
238
238
|
static VALUE
|
|
239
239
|
glu_NurbsProperty(obj, arg1, arg2, arg3)
|
|
240
240
|
VALUE obj, arg1, arg2, arg3;
|
|
241
241
|
{
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
242
|
+
struct nurbsdata *ndata;
|
|
243
|
+
GLenum property;
|
|
244
|
+
GLfloat value;
|
|
245
|
+
GetNURBS(arg1, ndata);
|
|
246
|
+
property = (GLenum)NUM2INT(arg2);
|
|
247
|
+
value = (GLfloat)NUM2DBL(arg3);
|
|
248
|
+
gluNurbsProperty(ndata->nobj, property, value);
|
|
249
|
+
|
|
250
|
+
return Qnil;
|
|
251
251
|
}
|
|
252
252
|
static VALUE
|
|
253
253
|
glu_GetNurbsProperty(obj, arg1, arg2)
|
|
254
254
|
VALUE obj, arg1, arg2;
|
|
255
255
|
{
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
256
|
+
struct nurbsdata *ndata;
|
|
257
|
+
GLenum property;
|
|
258
|
+
GLfloat value;
|
|
259
|
+
GetNURBS(arg1, ndata);
|
|
260
|
+
property = (GLenum)NUM2INT(arg2);
|
|
261
|
+
gluGetNurbsProperty(ndata->nobj, property, &value);
|
|
262
|
+
|
|
263
|
+
return cond_GLBOOL2RUBY_F(property,value);
|
|
264
264
|
}
|
|
265
265
|
static VALUE
|
|
266
266
|
glu_BeginCurve(obj, arg1)
|
|
267
267
|
VALUE obj, arg1;
|
|
268
268
|
{
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
269
|
+
struct nurbsdata *ndata;
|
|
270
|
+
GetNURBS(arg1, ndata);
|
|
271
|
+
rb_ary_push(n_current, arg1);
|
|
272
|
+
gluBeginCurve(ndata->nobj);
|
|
273
|
+
|
|
274
|
+
return Qnil;
|
|
275
275
|
}
|
|
276
276
|
static VALUE
|
|
277
277
|
glu_EndCurve(obj, arg1)
|
|
278
278
|
VALUE obj, arg1;
|
|
279
279
|
{
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
280
|
+
struct nurbsdata *ndata;
|
|
281
|
+
GetNURBS(arg1, ndata);
|
|
282
|
+
gluEndCurve(ndata->nobj);
|
|
283
|
+
|
|
284
|
+
for (;gms.len>0;gms.len--)
|
|
285
|
+
free(gms.ptr[gms.len-1]);
|
|
286
|
+
free(gms.ptr);
|
|
287
|
+
gms.ptr = NULL;
|
|
283
288
|
|
|
284
|
-
|
|
285
|
-
free(gms.ptr[gms.len-1]);
|
|
286
|
-
free(gms.ptr);
|
|
287
|
-
gms.ptr = NULL;
|
|
289
|
+
rb_ary_pop(n_current);
|
|
288
290
|
|
|
289
|
-
rb_ary_pop(n_current);
|
|
290
291
|
|
|
291
|
-
|
|
292
|
-
return Qnil;
|
|
292
|
+
return Qnil;
|
|
293
293
|
}
|
|
294
294
|
static VALUE
|
|
295
295
|
glu_NurbsCurve(argc,argv,obj)
|
|
@@ -297,84 +297,86 @@ int argc;
|
|
|
297
297
|
VALUE *argv;
|
|
298
298
|
VALUE obj;
|
|
299
299
|
{
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
300
|
+
struct nurbsdata *ndata;
|
|
301
|
+
GLint uknot_count;
|
|
302
|
+
GLfloat *uknot;
|
|
303
|
+
GLint u_stride;
|
|
304
|
+
GLint uorder;
|
|
305
|
+
GLfloat *ctlarray;
|
|
306
|
+
GLenum type;
|
|
307
|
+
GLfloat **gms_ptr;
|
|
308
|
+
|
|
309
|
+
VALUE args[7];
|
|
310
|
+
VALUE ary_ctl1;
|
|
311
|
+
|
|
312
|
+
switch (rb_scan_args(argc, argv, "52", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5], &args[6])) {
|
|
313
|
+
case 5:
|
|
314
|
+
uknot_count = (GLint)RARRAY_LENINT(args[1]);
|
|
315
|
+
uorder = (GLenum)NUM2INT(args[3]);
|
|
316
|
+
type = (GLenum)NUM2INT(args[4]);
|
|
317
|
+
u_stride = get_curve_dim(type);
|
|
318
|
+
|
|
319
|
+
uknot = ALLOC_N(GLfloat, uknot_count);
|
|
320
|
+
ary2cflt(args[1], uknot, uknot_count);
|
|
321
|
+
|
|
322
|
+
ary_ctl1 = rb_funcall(args[2],rb_intern("flatten"),0);
|
|
323
|
+
break;
|
|
324
|
+
case 7:
|
|
325
|
+
uknot_count = (GLint)NUM2INT(args[1]);
|
|
326
|
+
u_stride = (GLint)NUM2INT(args[3]);
|
|
327
|
+
uorder = (GLint)NUM2INT(args[5]);
|
|
328
|
+
type = (GLenum)NUM2INT(args[6]);
|
|
329
|
+
|
|
330
|
+
uknot = ALLOC_N(GLfloat, uknot_count);
|
|
331
|
+
ary2cflt(args[2], uknot, uknot_count);
|
|
332
|
+
|
|
333
|
+
ary_ctl1 = rb_funcall(args[4],rb_intern("flatten"),0);
|
|
334
|
+
break;
|
|
335
|
+
default:
|
|
336
|
+
rb_raise(rb_eArgError, "gluNurbsCurve needs 5 or 7 arguments");
|
|
337
|
+
}
|
|
338
|
+
ctlarray = ALLOC_N(GLfloat, u_stride*(uknot_count-uorder));
|
|
339
|
+
ary2cflt((VALUE)ary_ctl1, ctlarray, (uknot_count-uorder)*u_stride);
|
|
340
|
+
|
|
341
|
+
GetNURBS(args[0], ndata);
|
|
342
|
+
gluNurbsCurve(ndata->nobj, uknot_count, uknot, u_stride, ctlarray, uorder, type);
|
|
343
|
+
|
|
344
|
+
/* store the pointers */
|
|
345
|
+
gms_ptr = gms.ptr;
|
|
346
|
+
gms.ptr = REALLOC_N(gms_ptr, GLfloat*, gms.len+=2);
|
|
347
|
+
gms.ptr[gms.len - 2] = uknot;
|
|
348
|
+
gms.ptr[gms.len - 1] = ctlarray;
|
|
349
|
+
|
|
350
|
+
return Qnil;
|
|
349
351
|
}
|
|
350
352
|
static VALUE
|
|
351
353
|
glu_BeginSurface(obj, arg1)
|
|
352
354
|
VALUE obj, arg1;
|
|
353
355
|
{
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
356
|
+
struct nurbsdata *ndata;
|
|
357
|
+
GetNURBS(arg1, ndata);
|
|
358
|
+
rb_ary_push(n_current, arg1);
|
|
359
|
+
gluBeginSurface(ndata->nobj);
|
|
360
|
+
|
|
361
|
+
return Qnil;
|
|
360
362
|
}
|
|
361
363
|
static VALUE
|
|
362
364
|
glu_EndSurface(obj, arg1)
|
|
363
365
|
VALUE obj, arg1;
|
|
364
366
|
{
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
367
|
+
struct nurbsdata *ndata;
|
|
368
|
+
GetNURBS(arg1, ndata);
|
|
369
|
+
gluEndSurface(ndata->nobj);
|
|
370
|
+
|
|
371
|
+
for(; gms.len>0; gms.len--)
|
|
372
|
+
free(gms.ptr[gms.len-1]);
|
|
373
|
+
free(gms.ptr);
|
|
374
|
+
gms.ptr = NULL;
|
|
373
375
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
376
|
+
rb_ary_pop(n_current);
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
return Qnil;
|
|
378
380
|
}
|
|
379
381
|
|
|
380
382
|
static VALUE
|
|
@@ -383,102 +385,104 @@ int argc;
|
|
|
383
385
|
VALUE *argv;
|
|
384
386
|
VALUE obj;
|
|
385
387
|
{
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
388
|
+
struct nurbsdata *ndata;
|
|
389
|
+
GLint sknot_count;
|
|
390
|
+
GLfloat *sknot;
|
|
391
|
+
GLint tknot_count;
|
|
392
|
+
GLfloat *tknot;
|
|
393
|
+
GLint s_stride;
|
|
394
|
+
GLint t_stride;
|
|
395
|
+
GLfloat *ctlarray;
|
|
396
|
+
GLint sorder;
|
|
397
|
+
GLint torder;
|
|
398
|
+
GLenum type;
|
|
399
|
+
GLfloat **gms_ptr;
|
|
400
|
+
|
|
401
|
+
VALUE args[11];
|
|
402
|
+
VALUE ary_ctl1;
|
|
403
|
+
int type_len;
|
|
404
|
+
|
|
405
|
+
switch (rb_scan_args(argc, argv, "74", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5], &args[6], &args[7], &args[8], &args[9], &args[10])) {
|
|
406
|
+
case 7:
|
|
407
|
+
sknot_count = (GLint)RARRAY_LENINT(args[1]);
|
|
408
|
+
sknot = ALLOC_N(GLfloat, sknot_count);
|
|
409
|
+
ary2cflt(args[1], sknot, sknot_count);
|
|
410
|
+
|
|
411
|
+
tknot_count = (GLint)RARRAY_LENINT(args[2]);
|
|
412
|
+
tknot = ALLOC_N(GLfloat, tknot_count);
|
|
413
|
+
ary2cflt(args[2], tknot, tknot_count);
|
|
414
|
+
|
|
415
|
+
sorder = (GLint)NUM2INT(args[4]);
|
|
416
|
+
torder = (GLint)NUM2INT(args[5]);
|
|
417
|
+
type = (GLenum)NUM2INT(args[6]);
|
|
418
|
+
|
|
419
|
+
t_stride = get_surface_dim(type);
|
|
420
|
+
s_stride = t_stride * sorder;
|
|
421
|
+
|
|
422
|
+
ctlarray = ALLOC_N(GLfloat, (sknot_count-sorder)*(tknot_count-torder)*t_stride);
|
|
423
|
+
ary_ctl1 = rb_funcall(args[3],rb_intern("flatten"),0);
|
|
424
|
+
ary2cflt(ary_ctl1, ctlarray, (sknot_count-sorder)*(tknot_count-torder)*t_stride);
|
|
425
|
+
break;
|
|
426
|
+
case 11:
|
|
427
|
+
sknot_count = (GLint)NUM2INT(args[1]);
|
|
428
|
+
sknot = ALLOC_N(GLfloat, sknot_count);
|
|
429
|
+
ary2cflt(args[2], sknot, sknot_count);
|
|
430
|
+
|
|
431
|
+
tknot_count = (GLint)NUM2INT(args[3]);
|
|
432
|
+
tknot = ALLOC_N(GLfloat, tknot_count);
|
|
433
|
+
ary2cflt(args[4], tknot, tknot_count);
|
|
434
|
+
|
|
435
|
+
s_stride = (GLint)NUM2INT(args[5]);
|
|
436
|
+
t_stride = (GLint)NUM2INT(args[6]);
|
|
437
|
+
sorder = (GLint)NUM2INT(args[8]);
|
|
438
|
+
torder = (GLint)NUM2INT(args[9]);
|
|
439
|
+
type = (GLint)NUM2INT(args[10]);
|
|
440
|
+
type_len = get_surface_dim(type);
|
|
441
|
+
|
|
442
|
+
ctlarray = ALLOC_N(GLfloat, (sknot_count-sorder)*(tknot_count-torder)*type_len);
|
|
443
|
+
ary_ctl1 = rb_funcall(args[7],rb_intern("flatten"),0);
|
|
444
|
+
ary2cflt(ary_ctl1, ctlarray, (sknot_count-sorder)*(tknot_count-torder)*type_len);
|
|
445
|
+
break;
|
|
446
|
+
default:
|
|
447
|
+
rb_raise(rb_eArgError, "gluNurbsSurface needs 7 or 11 arguments");
|
|
448
|
+
return Qnil; /* not reached */
|
|
449
|
+
}
|
|
450
|
+
GetNURBS(args[0], ndata);
|
|
451
|
+
gluNurbsSurface(ndata->nobj, sknot_count, sknot, tknot_count, tknot,
|
|
452
|
+
s_stride, t_stride, ctlarray, sorder, torder, type);
|
|
453
|
+
|
|
454
|
+
/* store the pointers */
|
|
455
|
+
|
|
456
|
+
gms_ptr = gms.ptr;
|
|
457
|
+
gms.ptr = REALLOC_N(gms_ptr, GLfloat*, gms.len+=3);
|
|
458
|
+
gms.ptr[gms.len-3] = sknot;
|
|
459
|
+
gms.ptr[gms.len-2] = tknot;
|
|
460
|
+
gms.ptr[gms.len-1] = ctlarray;
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
return Qnil;
|
|
460
464
|
}
|
|
461
465
|
static VALUE
|
|
462
466
|
glu_BeginTrim(obj, arg1)
|
|
463
467
|
VALUE obj, arg1;
|
|
464
468
|
{
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
469
|
+
struct nurbsdata *ndata;
|
|
470
|
+
GetNURBS(arg1, ndata);
|
|
471
|
+
rb_ary_push(n_current, arg1);
|
|
472
|
+
gluBeginTrim(ndata->nobj);
|
|
473
|
+
|
|
474
|
+
return Qnil;
|
|
471
475
|
}
|
|
472
476
|
static VALUE
|
|
473
477
|
glu_EndTrim(obj, arg1)
|
|
474
478
|
VALUE obj, arg1;
|
|
475
479
|
{
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
480
|
+
struct nurbsdata *ndata;
|
|
481
|
+
GetNURBS(arg1, ndata);
|
|
482
|
+
gluEndTrim(ndata->nobj);
|
|
483
|
+
rb_ary_pop(n_current);
|
|
484
|
+
|
|
485
|
+
return Qnil;
|
|
482
486
|
}
|
|
483
487
|
static VALUE
|
|
484
488
|
glu_PwlCurve(argc, argv, obj)
|
|
@@ -486,68 +490,68 @@ int argc;
|
|
|
486
490
|
VALUE *argv;
|
|
487
491
|
VALUE obj;
|
|
488
492
|
{
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
493
|
+
struct nurbsdata *ndata;
|
|
494
|
+
GLint count;
|
|
495
|
+
GLfloat *array;
|
|
496
|
+
GLint stride;
|
|
497
|
+
GLenum type;
|
|
498
|
+
|
|
499
|
+
VALUE args[5];
|
|
500
|
+
VALUE ary_ctl1;
|
|
501
|
+
|
|
502
|
+
switch (rb_scan_args(argc, argv, "32", &args[0], &args[1], &args[2], &args[3], &args[4])) {
|
|
503
|
+
case 3:
|
|
504
|
+
count = (GLint)RARRAY_LENINT(args[1]);
|
|
505
|
+
type = NUM2INT(args[2]);
|
|
506
|
+
stride = (type == GLU_MAP1_TRIM_2 ? 2 : 3);
|
|
507
|
+
|
|
508
|
+
array = ALLOC_N(GLfloat, count*stride);
|
|
509
|
+
ary_ctl1 = rb_funcall(args[1],rb_intern("flatten"),0);
|
|
510
|
+
ary2cflt(ary_ctl1, array, count*stride);
|
|
511
|
+
break;
|
|
512
|
+
case 5:
|
|
513
|
+
count = NUM2INT(args[1]);
|
|
514
|
+
stride = NUM2INT(args[3]);
|
|
515
|
+
type = NUM2INT(args[4]);
|
|
516
|
+
|
|
517
|
+
array = ALLOC_N(GLfloat, count*stride);
|
|
518
|
+
ary_ctl1 = rb_funcall(args[2],rb_intern("flatten"),0);
|
|
519
|
+
ary2cflt(ary_ctl1, array, count*stride);
|
|
520
|
+
break;
|
|
521
|
+
default:
|
|
522
|
+
rb_raise(rb_eArgError, "gluPwlCurve needs 3 or 5 arguments");
|
|
523
|
+
return Qnil; /* not reached */
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
GetNURBS(args[0], ndata);
|
|
527
|
+
gluPwlCurve(ndata->nobj, count, array, stride, type);
|
|
528
|
+
free(array);
|
|
529
|
+
|
|
530
|
+
return Qnil;
|
|
527
531
|
}
|
|
528
532
|
|
|
529
533
|
static VALUE glu_LoadSamplingMatrices(obj,arg1,arg2,arg3,arg4)
|
|
530
534
|
VALUE obj, arg1,arg2,arg3,arg4;
|
|
531
535
|
{
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
+
struct nurbsdata *ndata;
|
|
537
|
+
GLfloat mdl_mtx[4*4];
|
|
538
|
+
GLfloat persp_mtx[4*4];
|
|
539
|
+
GLint viewport[4];
|
|
536
540
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
+
GetNURBS(arg1, ndata);
|
|
542
|
+
ary2cmatfloat(arg2,mdl_mtx,4,4);
|
|
543
|
+
ary2cmatfloat(arg3,persp_mtx,4,4);
|
|
544
|
+
ary2cint(arg4,viewport,4);
|
|
541
545
|
|
|
542
|
-
|
|
546
|
+
gluLoadSamplingMatrices(ndata->nobj,mdl_mtx,persp_mtx,viewport);
|
|
543
547
|
|
|
544
|
-
|
|
545
|
-
|
|
548
|
+
|
|
549
|
+
return Qnil;
|
|
546
550
|
}
|
|
547
551
|
|
|
548
552
|
/*
|
|
549
|
-
|
|
550
|
-
|
|
553
|
+
* Tesselation API
|
|
554
|
+
*/
|
|
551
555
|
static VALUE t_current;
|
|
552
556
|
#define TESS_DATA 0
|
|
553
557
|
#define TESS_BEGIN 1
|
|
@@ -569,39 +573,39 @@ static void
|
|
|
569
573
|
mark_tess(tdata)
|
|
570
574
|
struct tessdata* tdata;
|
|
571
575
|
{
|
|
572
|
-
|
|
573
|
-
|
|
576
|
+
if (tdata->tobj)
|
|
577
|
+
rb_gc_mark(tdata->t_ref);
|
|
574
578
|
}
|
|
575
579
|
static void
|
|
576
580
|
free_tess(tdata)
|
|
577
581
|
struct tessdata *tdata;
|
|
578
582
|
{
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
+
if (tdata->tobj)
|
|
584
|
+
gluDeleteTess(tdata->tobj);
|
|
585
|
+
tdata->t_ref = Qnil;
|
|
586
|
+
tdata->tobj = NULL;
|
|
583
587
|
}
|
|
584
588
|
static VALUE
|
|
585
589
|
glu_NewTess(obj)
|
|
586
590
|
VALUE obj;
|
|
587
591
|
{
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
592
|
+
VALUE ret;
|
|
593
|
+
struct tessdata *tdata;
|
|
594
|
+
ret = Data_Make_Struct(cTess, struct tessdata, mark_tess, free_tess, tdata);
|
|
595
|
+
tdata->tobj = gluNewTess();
|
|
596
|
+
tdata->t_ref = rb_ary_new2(REF_LAST);
|
|
597
|
+
|
|
598
|
+
return ret;
|
|
595
599
|
}
|
|
596
600
|
static VALUE
|
|
597
601
|
glu_DeleteTess(obj, arg1)
|
|
598
602
|
VALUE obj, arg1;
|
|
599
603
|
{
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
604
|
+
struct tessdata *tdata;
|
|
605
|
+
GetTESS(arg1, tdata);
|
|
606
|
+
free_tess(tdata);
|
|
607
|
+
|
|
608
|
+
return Qnil;
|
|
605
609
|
}
|
|
606
610
|
|
|
607
611
|
/* tess* callback function wrappers */
|
|
@@ -610,81 +614,81 @@ VALUE tess; \
|
|
|
610
614
|
struct tessdata *tdata; \
|
|
611
615
|
tess = rb_ary_entry(t_current, -1); \
|
|
612
616
|
if (tess == Qnil) \
|
|
613
|
-
|
|
617
|
+
return; \
|
|
614
618
|
GetTESS(tess, tdata);
|
|
615
619
|
|
|
616
620
|
static void CALLBACK
|
|
617
621
|
t_begin(type)
|
|
618
622
|
GLenum type;
|
|
619
623
|
{
|
|
620
|
-
|
|
621
|
-
|
|
624
|
+
TESS_CALLBACK_COMMON
|
|
625
|
+
rb_funcall(rb_ary_entry(tdata->t_ref, TESS_BEGIN), callId, 1, INT2NUM(type));
|
|
622
626
|
}
|
|
623
627
|
static void CALLBACK
|
|
624
628
|
t_edgeFlag(flag)
|
|
625
629
|
GLboolean flag;
|
|
626
630
|
{
|
|
627
|
-
|
|
628
|
-
|
|
631
|
+
TESS_CALLBACK_COMMON
|
|
632
|
+
rb_funcall(rb_ary_entry(tdata->t_ref, TESS_EDGE_FLAG), callId, 1, GLBOOL2RUBY(flag));
|
|
629
633
|
}
|
|
630
634
|
static void CALLBACK
|
|
631
635
|
t_vertex(data)
|
|
632
636
|
void* data;
|
|
633
637
|
{
|
|
634
|
-
|
|
635
|
-
|
|
638
|
+
TESS_CALLBACK_COMMON
|
|
639
|
+
rb_funcall(rb_ary_entry(tdata->t_ref, TESS_VERTEX), callId, 1, data);
|
|
636
640
|
}
|
|
637
641
|
static void CALLBACK
|
|
638
642
|
t_end()
|
|
639
643
|
{
|
|
640
|
-
|
|
641
|
-
|
|
644
|
+
TESS_CALLBACK_COMMON
|
|
645
|
+
rb_funcall(rb_ary_entry(tdata->t_ref, TESS_END), callId, 0);
|
|
642
646
|
}
|
|
643
647
|
static void CALLBACK
|
|
644
648
|
t_error(errorno)
|
|
645
649
|
GLenum errorno;
|
|
646
650
|
{
|
|
647
|
-
|
|
648
|
-
|
|
651
|
+
TESS_CALLBACK_COMMON
|
|
652
|
+
rb_funcall(rb_ary_entry(tdata->t_ref, TESS_ERROR), callId, 1, INT2NUM(errorno));
|
|
649
653
|
}
|
|
650
654
|
static void CALLBACK
|
|
651
655
|
t_begin_data(type, user_data)
|
|
652
656
|
GLenum type;
|
|
653
657
|
void* user_data;
|
|
654
658
|
{
|
|
655
|
-
|
|
656
|
-
|
|
659
|
+
TESS_CALLBACK_COMMON
|
|
660
|
+
rb_funcall(rb_ary_entry(tdata->t_ref, TESS_BEGIN_DATA), callId, 2, INT2NUM(type), user_data);
|
|
657
661
|
}
|
|
658
662
|
static void CALLBACK
|
|
659
663
|
t_edgeFlag_data(flag, user_data)
|
|
660
664
|
GLboolean flag;
|
|
661
665
|
void* user_data;
|
|
662
666
|
{
|
|
663
|
-
|
|
664
|
-
|
|
667
|
+
TESS_CALLBACK_COMMON
|
|
668
|
+
rb_funcall(rb_ary_entry(tdata->t_ref, TESS_EDGE_FLAG_DATA), callId, 2, GLBOOL2RUBY(flag), user_data);
|
|
665
669
|
}
|
|
666
670
|
static void CALLBACK
|
|
667
671
|
t_vertex_data(data, user_data)
|
|
668
672
|
void* data;
|
|
669
673
|
void* user_data;
|
|
670
674
|
{
|
|
671
|
-
|
|
672
|
-
|
|
675
|
+
TESS_CALLBACK_COMMON
|
|
676
|
+
rb_funcall(rb_ary_entry(tdata->t_ref, TESS_VERTEX_DATA), callId, 2, data, user_data);
|
|
673
677
|
}
|
|
674
678
|
static void CALLBACK
|
|
675
679
|
t_end_data(user_data)
|
|
676
680
|
void* user_data;
|
|
677
681
|
{
|
|
678
|
-
|
|
679
|
-
|
|
682
|
+
TESS_CALLBACK_COMMON
|
|
683
|
+
rb_funcall(rb_ary_entry(tdata->t_ref, TESS_END_DATA), callId, 1, user_data);
|
|
680
684
|
}
|
|
681
685
|
static void CALLBACK
|
|
682
686
|
t_error_data(errorno, user_data)
|
|
683
687
|
GLenum errorno;
|
|
684
688
|
void* user_data;
|
|
685
689
|
{
|
|
686
|
-
|
|
687
|
-
|
|
690
|
+
TESS_CALLBACK_COMMON
|
|
691
|
+
rb_funcall(rb_ary_entry(tdata->t_ref, TESS_ERROR_DATA), callId, 2, INT2NUM(errorno), user_data);
|
|
688
692
|
}
|
|
689
693
|
|
|
690
694
|
static void CALLBACK
|
|
@@ -694,21 +698,21 @@ void* vertex_data[4];
|
|
|
694
698
|
GLfloat weight[4];
|
|
695
699
|
void** outData;
|
|
696
700
|
{
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
701
|
+
VALUE rb_coord, rb_vertex_data, rb_weight;
|
|
702
|
+
int i;
|
|
703
|
+
TESS_CALLBACK_COMMON
|
|
700
704
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
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), callId, 3, rb_coord, rb_vertex_data, rb_weight);
|
|
715
|
+
rb_ary_push(rb_ary_entry(tdata->t_ref, TESS_OUTDATA), (VALUE)*outData);
|
|
712
716
|
}
|
|
713
717
|
|
|
714
718
|
static void CALLBACK
|
|
@@ -719,23 +723,23 @@ GLfloat weight[4];
|
|
|
719
723
|
void** outData;
|
|
720
724
|
void* user_data;
|
|
721
725
|
{
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
726
|
+
VALUE rb_coord, rb_vertex_data, rb_weight;
|
|
727
|
+
int i;
|
|
728
|
+
TESS_CALLBACK_COMMON
|
|
729
|
+
|
|
730
|
+
rb_coord = rb_ary_new2(3);
|
|
731
|
+
for (i = 0; i < 3; i++)
|
|
732
|
+
rb_ary_store(rb_coord, i, rb_float_new(coords[i]));
|
|
733
|
+
rb_vertex_data = rb_ary_new2(4);
|
|
734
|
+
for (i = 0; i < 4; i++)
|
|
735
|
+
rb_ary_store(rb_vertex_data, i, (VALUE)vertex_data[i]);
|
|
736
|
+
rb_weight = rb_ary_new2(4);
|
|
737
|
+
for (i = 0; i < 4; i++)
|
|
738
|
+
rb_ary_store(rb_weight, i, rb_float_new(weight[i]));
|
|
735
739
|
|
|
736
|
-
|
|
740
|
+
*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);
|
|
737
741
|
|
|
738
|
-
|
|
742
|
+
rb_ary_push(rb_ary_entry(tdata->t_ref, TESS_OUTDATA), (VALUE)*outData);
|
|
739
743
|
}
|
|
740
744
|
|
|
741
745
|
#undef TESS_CALLBACK_COMMON
|
|
@@ -744,94 +748,94 @@ static VALUE
|
|
|
744
748
|
glu_TessProperty(obj, arg1, arg2, arg3)
|
|
745
749
|
VALUE obj, arg1, arg2, arg3;
|
|
746
750
|
{
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
751
|
+
struct tessdata* tdata;
|
|
752
|
+
GLenum property;
|
|
753
|
+
GLdouble value;
|
|
754
|
+
GetTESS(arg1, tdata);
|
|
755
|
+
property = (GLenum)NUM2INT(arg2);
|
|
752
756
|
if (property == GLU_TESS_BOUNDARY_ONLY) {
|
|
753
757
|
value = (GLdouble)RUBYBOOL2GL(arg3);
|
|
754
758
|
} else {
|
|
755
759
|
value = (GLdouble)NUM2DBL(arg3);
|
|
756
760
|
}
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
761
|
+
gluTessProperty(tdata->tobj, property, value);
|
|
762
|
+
|
|
763
|
+
return Qnil;
|
|
760
764
|
}
|
|
761
765
|
static VALUE
|
|
762
766
|
glu_GetTessProperty(obj, arg1, arg2)
|
|
763
767
|
VALUE obj, arg1, arg2;
|
|
764
768
|
{
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
769
|
+
struct tessdata* tdata;
|
|
770
|
+
GLenum property;
|
|
771
|
+
GLdouble value;
|
|
772
|
+
GetTESS(arg1, tdata);
|
|
773
|
+
property = (GLenum)NUM2INT(arg2);
|
|
774
|
+
gluGetTessProperty(tdata->tobj, property, &value);
|
|
775
|
+
|
|
776
|
+
return cond_GLBOOL2RUBY_D(property,value);
|
|
773
777
|
}
|
|
774
778
|
static VALUE
|
|
775
779
|
glu_TessNormal(obj, arg1, arg2, arg3, arg4)
|
|
776
780
|
VALUE obj, arg1, arg2, arg3, arg4;
|
|
777
781
|
{
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
782
|
+
struct tessdata* tdata;
|
|
783
|
+
GLdouble x, y, z;
|
|
784
|
+
GetTESS(arg1, tdata);
|
|
785
|
+
x = (GLdouble)NUM2DBL(arg2);
|
|
786
|
+
y = (GLdouble)NUM2DBL(arg3);
|
|
787
|
+
z = (GLdouble)NUM2DBL(arg4);
|
|
788
|
+
gluTessNormal(tdata->tobj, x, y, z);
|
|
789
|
+
|
|
790
|
+
return Qnil;
|
|
787
791
|
}
|
|
788
792
|
static VALUE
|
|
789
793
|
glu_TessBeginPolygon(obj, arg1, arg2)
|
|
790
794
|
VALUE obj, arg1, arg2;
|
|
791
795
|
{
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
796
|
+
struct tessdata* tdata;
|
|
797
|
+
GetTESS(arg1, tdata);
|
|
798
|
+
rb_ary_store(tdata->t_ref, TESS_USERDATA, arg2);
|
|
799
|
+
rb_ary_store(tdata->t_ref, TESS_OUTDATA, rb_ary_new());
|
|
800
|
+
rb_ary_store(tdata->t_ref, TESS_DATA, rb_ary_new());
|
|
801
|
+
rb_ary_push(t_current, arg1);
|
|
802
|
+
gluTessBeginPolygon(tdata->tobj, (void*)arg2);
|
|
803
|
+
|
|
804
|
+
return Qnil;
|
|
801
805
|
}
|
|
802
806
|
static VALUE
|
|
803
807
|
glu_TessEndPolygon(obj, arg1)
|
|
804
808
|
VALUE obj, arg1;
|
|
805
809
|
{
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
810
|
+
struct tessdata* tdata;
|
|
811
|
+
GetTESS(arg1, tdata);
|
|
812
|
+
gluTessEndPolygon(tdata->tobj);
|
|
813
|
+
rb_ary_store(tdata->t_ref, TESS_USERDATA, Qnil);
|
|
814
|
+
rb_ary_store(tdata->t_ref, TESS_OUTDATA, Qnil);
|
|
815
|
+
rb_ary_store(tdata->t_ref, TESS_DATA, Qnil);
|
|
816
|
+
rb_ary_pop(t_current);
|
|
817
|
+
|
|
818
|
+
return Qnil;
|
|
815
819
|
}
|
|
816
820
|
static VALUE
|
|
817
821
|
glu_TessBeginContour(obj, arg1)
|
|
818
822
|
VALUE obj, arg1;
|
|
819
823
|
{
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
824
|
+
struct tessdata* tdata;
|
|
825
|
+
GetTESS(arg1, tdata);
|
|
826
|
+
gluTessBeginContour(tdata->tobj);
|
|
827
|
+
|
|
828
|
+
return Qnil;
|
|
825
829
|
}
|
|
826
830
|
static VALUE
|
|
827
831
|
glu_TessEndContour(obj, arg1)
|
|
828
832
|
VALUE obj, arg1;
|
|
829
833
|
{
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
834
|
+
struct tessdata* tdata;
|
|
835
|
+
GetTESS(arg1, tdata);
|
|
836
|
+
gluTessEndContour(tdata->tobj);
|
|
837
|
+
|
|
838
|
+
return Qnil;
|
|
835
839
|
}
|
|
836
840
|
|
|
837
841
|
#define TESS_CALLBACK_CASE(_type_,_function_) \
|
|
@@ -847,29 +851,29 @@ static VALUE
|
|
|
847
851
|
glu_TessCallback(obj, arg1, arg2, arg3)
|
|
848
852
|
VALUE obj, arg1, arg2, arg3;
|
|
849
853
|
{
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
854
|
+
struct tessdata* tdata;
|
|
855
|
+
GLenum type;
|
|
856
|
+
GetTESS(arg1, tdata);
|
|
857
|
+
type = (GLenum)NUM2INT(arg2);
|
|
858
|
+
if (!rb_obj_is_kind_of(arg3,rb_cProc) && !NIL_P(arg3))
|
|
859
|
+
rb_raise(rb_eTypeError, "gluTessCallback needs Proc Object:%s",rb_class2name(CLASS_OF(arg3)));
|
|
860
|
+
|
|
861
|
+
switch (type) {
|
|
862
|
+
TESS_CALLBACK_CASE(TESS_BEGIN,t_begin)
|
|
863
|
+
TESS_CALLBACK_CASE(TESS_BEGIN_DATA,t_begin_data)
|
|
864
|
+
TESS_CALLBACK_CASE(TESS_EDGE_FLAG,t_edgeFlag)
|
|
865
|
+
TESS_CALLBACK_CASE(TESS_EDGE_FLAG_DATA,t_edgeFlag_data)
|
|
866
|
+
TESS_CALLBACK_CASE(TESS_VERTEX,t_vertex)
|
|
867
|
+
TESS_CALLBACK_CASE(TESS_VERTEX_DATA,t_vertex_data)
|
|
868
|
+
TESS_CALLBACK_CASE(TESS_END,t_end)
|
|
869
|
+
TESS_CALLBACK_CASE(TESS_END_DATA,t_end_data)
|
|
870
|
+
TESS_CALLBACK_CASE(TESS_ERROR,t_error)
|
|
871
|
+
TESS_CALLBACK_CASE(TESS_ERROR_DATA,t_error_data)
|
|
872
|
+
TESS_CALLBACK_CASE(TESS_COMBINE,t_combine)
|
|
873
|
+
TESS_CALLBACK_CASE(TESS_COMBINE_DATA,t_combine_data)
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
return Qnil;
|
|
873
877
|
}
|
|
874
878
|
#undef TESS_CALLBACK_CASE
|
|
875
879
|
|
|
@@ -877,94 +881,94 @@ static VALUE
|
|
|
877
881
|
glu_BeginPolygon(obj, arg1)
|
|
878
882
|
VALUE obj, arg1;
|
|
879
883
|
{
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
884
|
+
struct tessdata* tdata;
|
|
885
|
+
GetTESS(arg1, tdata);
|
|
886
|
+
rb_ary_store(tdata->t_ref, TESS_DATA, rb_ary_new());
|
|
887
|
+
rb_ary_push(t_current, arg1);
|
|
888
|
+
gluBeginPolygon(tdata->tobj);
|
|
889
|
+
|
|
890
|
+
return Qnil;
|
|
887
891
|
}
|
|
888
892
|
static VALUE
|
|
889
893
|
glu_TessVertex(obj, arg1, arg2, arg3)
|
|
890
894
|
VALUE obj, arg1, arg2, arg3;
|
|
891
895
|
{
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
896
|
+
struct tessdata* tdata;
|
|
897
|
+
GLdouble v[3] = {0.0,0.0,0.0};
|
|
898
|
+
GetTESS(arg1, tdata);
|
|
899
|
+
rb_ary_push(rb_ary_entry(tdata->t_ref, TESS_DATA), arg3);
|
|
900
|
+
Check_Type(arg2,T_ARRAY);
|
|
901
|
+
ary2cdbl(arg2, v, 3);
|
|
902
|
+
gluTessVertex(tdata->tobj, v,(void *)arg3);
|
|
903
|
+
|
|
904
|
+
return Qnil;
|
|
901
905
|
}
|
|
902
906
|
static VALUE
|
|
903
907
|
glu_NextContour(obj, arg1, arg2)
|
|
904
908
|
VALUE obj, arg1, arg2;
|
|
905
909
|
{
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
910
|
+
struct tessdata* tdata;
|
|
911
|
+
GLenum type;
|
|
912
|
+
GetTESS(arg1, tdata);
|
|
913
|
+
type = (GLenum)NUM2INT(arg2);
|
|
914
|
+
gluNextContour(tdata->tobj, type);
|
|
915
|
+
|
|
916
|
+
return Qnil;
|
|
913
917
|
}
|
|
914
918
|
static VALUE
|
|
915
919
|
glu_EndPolygon(obj, arg1)
|
|
916
920
|
VALUE obj, arg1;
|
|
917
921
|
{
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
922
|
+
struct tessdata* tdata;
|
|
923
|
+
GetTESS(arg1, tdata);
|
|
924
|
+
gluEndPolygon(tdata->tobj);
|
|
925
|
+
rb_ary_store(tdata->t_ref, TESS_DATA, Qnil);
|
|
926
|
+
rb_ary_pop(t_current);
|
|
927
|
+
|
|
928
|
+
return Qnil;
|
|
925
929
|
}
|
|
926
930
|
|
|
927
931
|
/*
|
|
928
|
-
|
|
929
|
-
|
|
932
|
+
* Quadric API
|
|
933
|
+
*/
|
|
930
934
|
static VALUE q_current;
|
|
931
935
|
|
|
932
936
|
static void CALLBACK
|
|
933
937
|
q_error(errorno)
|
|
934
938
|
GLenum errorno;
|
|
935
939
|
{
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
940
|
+
VALUE quad;
|
|
941
|
+
struct quaddata *qdata;
|
|
942
|
+
quad = rb_ary_entry(q_current, -1);
|
|
943
|
+
if (quad == Qnil)
|
|
944
|
+
return;
|
|
945
|
+
GetQUAD(quad, qdata);
|
|
946
|
+
rb_funcall(rb_ary_entry(qdata->q_ref, GLU_ERROR), callId, 1, INT2NUM(errorno));
|
|
943
947
|
}
|
|
944
948
|
|
|
945
949
|
static VALUE
|
|
946
950
|
glu_QuadricCallback(obj, arg1, arg2, arg3)
|
|
947
951
|
VALUE obj, arg1, arg2, arg3;
|
|
948
952
|
{
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
953
|
+
struct quaddata* qdata;
|
|
954
|
+
GLenum type;
|
|
955
|
+
GetQUAD(arg1, qdata);
|
|
956
|
+
type = (GLenum)NUM2INT(arg2);
|
|
957
|
+
if (!rb_obj_is_kind_of(arg3,rb_cProc) && !NIL_P(arg3))
|
|
958
|
+
rb_raise(rb_eTypeError, "gluQuadricCallback needs Proc Object:%s",rb_class2name(CLASS_OF(arg3)));
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
if (type!=GLU_ERROR)
|
|
962
|
+
return Qnil;
|
|
955
963
|
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
964
|
+
rb_ary_store(qdata->q_ref, type, arg3);
|
|
965
|
+
if (NIL_P(arg3))
|
|
966
|
+
gluQuadricCallback(qdata->qobj, type, NULL);
|
|
967
|
+
else
|
|
968
|
+
gluQuadricCallback(qdata->qobj, type, q_error);
|
|
959
969
|
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
gluQuadricCallback(qdata->qobj, type, NULL);
|
|
963
|
-
else
|
|
964
|
-
gluQuadricCallback(qdata->qobj, type, q_error);
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
return Qnil;
|
|
970
|
+
|
|
971
|
+
return Qnil;
|
|
968
972
|
}
|
|
969
973
|
|
|
970
974
|
static void
|
|
@@ -973,177 +977,177 @@ struct quaddata *qdata;
|
|
|
973
977
|
{
|
|
974
978
|
if (qdata->qobj) gluDeleteQuadric(qdata->qobj);
|
|
975
979
|
qdata->qobj = NULL;
|
|
976
|
-
|
|
980
|
+
qdata->q_ref = Qnil;
|
|
977
981
|
}
|
|
978
982
|
static void
|
|
979
983
|
mark_quad(qdata)
|
|
980
984
|
struct quaddata* qdata;
|
|
981
985
|
{
|
|
982
|
-
|
|
983
|
-
|
|
986
|
+
if (qdata->qobj)
|
|
987
|
+
rb_gc_mark(qdata->q_ref);
|
|
984
988
|
}
|
|
985
989
|
static VALUE
|
|
986
990
|
glu_NewQuadric(obj)
|
|
987
991
|
VALUE obj;
|
|
988
992
|
{
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
993
|
+
VALUE ret;
|
|
994
|
+
struct quaddata *qdata;
|
|
995
|
+
ret = Data_Make_Struct(cQuad, struct quaddata, mark_quad, free_quad, qdata);
|
|
996
|
+
qdata->qobj = gluNewQuadric();
|
|
997
|
+
qdata->q_ref = rb_ary_new2(REF_LAST);
|
|
998
|
+
|
|
999
|
+
return ret;
|
|
996
1000
|
}
|
|
997
1001
|
static VALUE
|
|
998
1002
|
glu_DeleteQuadric(obj, arg1)
|
|
999
1003
|
VALUE obj, arg1;
|
|
1000
1004
|
{
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1005
|
+
struct quaddata *qdata;
|
|
1006
|
+
GetQUAD(arg1, qdata);
|
|
1007
|
+
free_quad(qdata);
|
|
1008
|
+
|
|
1009
|
+
return Qnil;
|
|
1006
1010
|
}
|
|
1007
1011
|
static VALUE
|
|
1008
1012
|
glu_QuadricNormals(obj, arg1, arg2)
|
|
1009
1013
|
VALUE obj, arg1, arg2;
|
|
1010
1014
|
{
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1015
|
+
struct quaddata* qdata;
|
|
1016
|
+
GLenum normals;
|
|
1017
|
+
GetQUAD(arg1, qdata);
|
|
1018
|
+
normals = (GLenum)NUM2INT(arg2);
|
|
1019
|
+
gluQuadricNormals(qdata->qobj, normals);
|
|
1020
|
+
|
|
1021
|
+
return Qnil;
|
|
1018
1022
|
}
|
|
1019
1023
|
static VALUE
|
|
1020
1024
|
glu_QuadricTexture(obj, arg1, arg2)
|
|
1021
1025
|
VALUE obj, arg1, arg2;
|
|
1022
1026
|
{
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1027
|
+
struct quaddata* qdata;
|
|
1028
|
+
GLboolean textureCoords;
|
|
1029
|
+
GetQUAD(arg1, qdata);
|
|
1030
|
+
textureCoords = (GLboolean)RUBYBOOL2GL(arg2);
|
|
1031
|
+
gluQuadricTexture(qdata->qobj, textureCoords);
|
|
1032
|
+
|
|
1033
|
+
return Qnil;
|
|
1030
1034
|
}
|
|
1031
1035
|
static VALUE
|
|
1032
1036
|
glu_QuadricOrientation(obj, arg1, arg2)
|
|
1033
1037
|
VALUE obj, arg1, arg2;
|
|
1034
1038
|
{
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1039
|
+
struct quaddata* qdata;
|
|
1040
|
+
GLenum orientation;
|
|
1041
|
+
GetQUAD(arg1, qdata);
|
|
1042
|
+
orientation = (GLenum)NUM2INT(arg2);
|
|
1043
|
+
gluQuadricOrientation(qdata->qobj, orientation);
|
|
1044
|
+
|
|
1045
|
+
return Qnil;
|
|
1042
1046
|
}
|
|
1043
1047
|
static VALUE
|
|
1044
1048
|
glu_QuadricDrawStyle(obj, arg1, arg2)
|
|
1045
1049
|
VALUE obj, arg1, arg2;
|
|
1046
1050
|
{
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1051
|
+
struct quaddata* qdata;
|
|
1052
|
+
GLenum drawStyle;
|
|
1053
|
+
GetQUAD(arg1, qdata);
|
|
1054
|
+
drawStyle = (GLenum)NUM2INT(arg2);
|
|
1055
|
+
gluQuadricDrawStyle(qdata->qobj, drawStyle);
|
|
1056
|
+
|
|
1057
|
+
return Qnil;
|
|
1054
1058
|
}
|
|
1055
1059
|
static VALUE
|
|
1056
1060
|
glu_Cylinder(obj, arg1, arg2, arg3, arg4, arg5, arg6)
|
|
1057
1061
|
VALUE obj, arg1, arg2, arg3, arg4, arg5, arg6;
|
|
1058
1062
|
{
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1063
|
+
struct quaddata* qdata;
|
|
1064
|
+
GLdouble baseRadius;
|
|
1065
|
+
GLdouble topRadius;
|
|
1066
|
+
GLdouble height;
|
|
1067
|
+
GLint slices;
|
|
1068
|
+
GLint stacks;
|
|
1069
|
+
|
|
1070
|
+
GetQUAD(arg1, qdata);
|
|
1071
|
+
baseRadius = (GLdouble)NUM2DBL(arg2);
|
|
1072
|
+
topRadius = (GLdouble)NUM2DBL(arg3);
|
|
1073
|
+
height = (GLdouble)NUM2DBL(arg4);
|
|
1074
|
+
slices = (GLint)NUM2INT(arg5);
|
|
1075
|
+
stacks = (GLint)NUM2INT(arg6);
|
|
1076
|
+
|
|
1077
|
+
rb_ary_push(q_current, arg1);
|
|
1078
|
+
gluCylinder(qdata->qobj, baseRadius, topRadius, height, slices, stacks);
|
|
1079
|
+
rb_ary_pop(q_current);
|
|
1080
|
+
|
|
1081
|
+
return Qnil;
|
|
1078
1082
|
}
|
|
1079
1083
|
static VALUE
|
|
1080
1084
|
glu_Disk(obj, arg1, arg2, arg3, arg4, arg5)
|
|
1081
1085
|
VALUE obj, arg1, arg2, arg3, arg4, arg5;
|
|
1082
1086
|
{
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1087
|
+
struct quaddata* qdata;
|
|
1088
|
+
GLdouble innerRadius;
|
|
1089
|
+
GLdouble outerRadius;
|
|
1090
|
+
GLint slices;
|
|
1091
|
+
GLint loops;
|
|
1092
|
+
|
|
1093
|
+
GetQUAD(arg1, qdata);
|
|
1094
|
+
innerRadius = (GLdouble)NUM2DBL(arg2);
|
|
1095
|
+
outerRadius = (GLdouble)NUM2DBL(arg3);
|
|
1096
|
+
slices = (GLint)NUM2INT(arg4);
|
|
1097
|
+
loops = (GLint)NUM2INT(arg5);
|
|
1098
|
+
|
|
1099
|
+
rb_ary_push(q_current, arg1);
|
|
1100
|
+
|
|
1101
|
+
gluDisk(qdata->qobj, innerRadius, outerRadius, slices, loops);
|
|
1102
|
+
rb_ary_pop(q_current);
|
|
1103
|
+
|
|
1104
|
+
return Qnil;
|
|
1101
1105
|
}
|
|
1102
1106
|
static VALUE
|
|
1103
1107
|
glu_PartialDisk(obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
|
|
1104
1108
|
VALUE obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7;
|
|
1105
1109
|
{
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1110
|
+
struct quaddata* qdata;
|
|
1111
|
+
GLdouble innerRadius;
|
|
1112
|
+
GLdouble outerRadius;
|
|
1113
|
+
GLint slices;
|
|
1114
|
+
GLint loops;
|
|
1115
|
+
GLdouble startAngle;
|
|
1116
|
+
GLdouble sweepAngle;
|
|
1117
|
+
|
|
1118
|
+
GetQUAD(arg1, qdata);
|
|
1119
|
+
innerRadius = (GLdouble)NUM2DBL(arg2);
|
|
1120
|
+
outerRadius = (GLdouble)NUM2DBL(arg3);
|
|
1121
|
+
slices = (GLint)NUM2INT(arg4);
|
|
1122
|
+
loops = (GLint)NUM2INT(arg5);
|
|
1123
|
+
startAngle = (GLdouble)NUM2DBL(arg6);
|
|
1124
|
+
sweepAngle = (GLdouble)NUM2DBL(arg7);
|
|
1125
|
+
|
|
1126
|
+
rb_ary_push(q_current, arg1);
|
|
1127
|
+
gluPartialDisk(qdata->qobj, innerRadius, outerRadius, slices, loops, startAngle, sweepAngle);
|
|
1128
|
+
rb_ary_pop(q_current);
|
|
1129
|
+
|
|
1130
|
+
return Qnil;
|
|
1127
1131
|
}
|
|
1128
1132
|
static VALUE
|
|
1129
1133
|
glu_Sphere(obj, arg1, arg2, arg3, arg4)
|
|
1130
1134
|
VALUE obj, arg1, arg2, arg3, arg4;
|
|
1131
1135
|
{
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
+
struct quaddata* qdata;
|
|
1137
|
+
GLdouble radius;
|
|
1138
|
+
GLint slices;
|
|
1139
|
+
GLint stacks;
|
|
1140
|
+
|
|
1141
|
+
GetQUAD(arg1, qdata);
|
|
1142
|
+
radius = (GLdouble)NUM2DBL(arg2);
|
|
1143
|
+
slices = (GLint)NUM2INT(arg3);
|
|
1144
|
+
stacks = (GLint)NUM2INT(arg4);
|
|
1136
1145
|
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
stacks = (GLint)NUM2INT(arg4);
|
|
1146
|
+
rb_ary_push(q_current, arg1);
|
|
1147
|
+
gluSphere(qdata->qobj, radius, slices, stacks);
|
|
1148
|
+
rb_ary_pop(q_current);
|
|
1141
1149
|
|
|
1142
|
-
|
|
1143
|
-
gluSphere(qdata->qobj, radius, slices, stacks);
|
|
1144
|
-
rb_ary_pop(q_current);
|
|
1145
|
-
|
|
1146
|
-
return Qnil;
|
|
1150
|
+
return Qnil;
|
|
1147
1151
|
}
|
|
1148
1152
|
|
|
1149
1153
|
/* */
|
|
@@ -1152,59 +1156,59 @@ static VALUE
|
|
|
1152
1156
|
glu_LookAt(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)
|
|
1153
1157
|
VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9;
|
|
1154
1158
|
{
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1159
|
+
GLdouble eyex;
|
|
1160
|
+
GLdouble eyey;
|
|
1161
|
+
GLdouble eyez;
|
|
1162
|
+
GLdouble centerx;
|
|
1163
|
+
GLdouble centery;
|
|
1164
|
+
GLdouble centerz;
|
|
1165
|
+
GLdouble upx;
|
|
1166
|
+
GLdouble upy;
|
|
1167
|
+
GLdouble upz;
|
|
1168
|
+
eyex = (GLdouble)NUM2DBL(arg1);
|
|
1169
|
+
eyey = (GLdouble)NUM2DBL(arg2);
|
|
1170
|
+
eyez = (GLdouble)NUM2DBL(arg3);
|
|
1171
|
+
centerx = (GLdouble)NUM2DBL(arg4);
|
|
1172
|
+
centery = (GLdouble)NUM2DBL(arg5);
|
|
1173
|
+
centerz = (GLdouble)NUM2DBL(arg6);
|
|
1174
|
+
upx = (GLdouble)NUM2DBL(arg7);
|
|
1175
|
+
upy = (GLdouble)NUM2DBL(arg8);
|
|
1176
|
+
upz = (GLdouble)NUM2DBL(arg9);
|
|
1177
|
+
gluLookAt( eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz );
|
|
1178
|
+
|
|
1179
|
+
return Qnil;
|
|
1176
1180
|
}
|
|
1177
1181
|
static VALUE
|
|
1178
1182
|
glu_Ortho2D(obj,arg1,arg2,arg3,arg4)
|
|
1179
1183
|
VALUE obj,arg1,arg2,arg3,arg4;
|
|
1180
1184
|
{
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1185
|
+
GLdouble left;
|
|
1186
|
+
GLdouble right;
|
|
1187
|
+
GLdouble bottom;
|
|
1188
|
+
GLdouble top;
|
|
1189
|
+
left = (GLdouble)NUM2DBL(arg1);
|
|
1190
|
+
right = (GLdouble)NUM2DBL(arg2);
|
|
1191
|
+
bottom = (GLdouble)NUM2DBL(arg3);
|
|
1192
|
+
top = (GLdouble)NUM2DBL(arg4);
|
|
1193
|
+
gluOrtho2D(left,right,bottom,top);
|
|
1194
|
+
|
|
1195
|
+
return Qnil;
|
|
1192
1196
|
}
|
|
1193
1197
|
static VALUE
|
|
1194
1198
|
glu_Perspective(obj,arg1,arg2,arg3,arg4)
|
|
1195
1199
|
VALUE obj,arg1,arg2,arg3,arg4;
|
|
1196
1200
|
{
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1201
|
+
GLdouble fovy;
|
|
1202
|
+
GLdouble aspect;
|
|
1203
|
+
GLdouble zNear;
|
|
1204
|
+
GLdouble zFar;
|
|
1205
|
+
fovy = (GLdouble)NUM2DBL(arg1);
|
|
1206
|
+
aspect = (GLdouble)NUM2DBL(arg2);
|
|
1207
|
+
zNear = (GLdouble)NUM2DBL(arg3);
|
|
1208
|
+
zFar = (GLdouble)NUM2DBL(arg4);
|
|
1209
|
+
gluPerspective(fovy,aspect,zNear,zFar);
|
|
1210
|
+
|
|
1211
|
+
return Qnil;
|
|
1208
1212
|
}
|
|
1209
1213
|
static VALUE
|
|
1210
1214
|
glu_PickMatrix(argc,argv,obj)
|
|
@@ -1212,38 +1216,38 @@ int argc;
|
|
|
1212
1216
|
VALUE* argv;
|
|
1213
1217
|
VALUE obj;
|
|
1214
1218
|
{
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1219
|
+
GLdouble x;
|
|
1220
|
+
GLdouble y;
|
|
1221
|
+
GLdouble width;
|
|
1222
|
+
GLdouble height;
|
|
1223
|
+
GLint viewport[4];
|
|
1224
|
+
|
|
1225
|
+
VALUE args[5];
|
|
1226
|
+
|
|
1227
|
+
switch (rb_scan_args(argc, argv, "23", &args[0], &args[1], &args[2], &args[3], &args[4])) {
|
|
1228
|
+
case 2:
|
|
1229
|
+
width = 5.0f;
|
|
1230
|
+
height = 5.0f;
|
|
1231
|
+
glGetIntegerv(GL_VIEWPORT, viewport);
|
|
1232
|
+
break;
|
|
1233
|
+
case 4:
|
|
1234
|
+
width = (GLdouble)NUM2DBL(args[2]);
|
|
1235
|
+
height = (GLdouble)NUM2DBL(args[3]);
|
|
1236
|
+
glGetIntegerv(GL_VIEWPORT, viewport);
|
|
1237
|
+
break;
|
|
1238
|
+
case 5:
|
|
1239
|
+
width = (GLdouble)NUM2DBL(args[2]);
|
|
1240
|
+
height = (GLdouble)NUM2DBL(args[3]);
|
|
1241
|
+
ary2cint(args[4], viewport, 4);
|
|
1242
|
+
break;
|
|
1243
|
+
default:
|
|
1244
|
+
rb_raise(rb_eArgError, "gluPickMatrix needs 2,4 or 5 parameters");
|
|
1245
|
+
}
|
|
1246
|
+
x = (GLdouble)NUM2DBL(args[0]);
|
|
1247
|
+
y = (GLdouble)NUM2DBL(args[1]);
|
|
1248
|
+
gluPickMatrix(x, y, width, height, viewport);
|
|
1249
|
+
|
|
1250
|
+
return Qnil;
|
|
1247
1251
|
}
|
|
1248
1252
|
|
|
1249
1253
|
static VALUE
|
|
@@ -1252,44 +1256,44 @@ int argc;
|
|
|
1252
1256
|
VALUE* argv;
|
|
1253
1257
|
VALUE obj;
|
|
1254
1258
|
{
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1259
|
+
GLdouble ox;
|
|
1260
|
+
GLdouble oy;
|
|
1261
|
+
GLdouble oz;
|
|
1262
|
+
GLdouble mdl_mtx[4*4];
|
|
1263
|
+
GLdouble prj_mtx[4*4];
|
|
1264
|
+
GLint vport[4];
|
|
1265
|
+
GLdouble wx;
|
|
1266
|
+
GLdouble wy;
|
|
1267
|
+
GLdouble wz;
|
|
1268
|
+
|
|
1269
|
+
VALUE args[6];
|
|
1270
|
+
|
|
1271
|
+
switch (rb_scan_args(argc, argv, "33", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5])) {
|
|
1272
|
+
case 3:
|
|
1273
|
+
glGetDoublev(GL_MODELVIEW_MATRIX, mdl_mtx);
|
|
1274
|
+
glGetDoublev(GL_PROJECTION_MATRIX, prj_mtx);
|
|
1275
|
+
glGetIntegerv(GL_VIEWPORT, vport);
|
|
1276
|
+
break;
|
|
1277
|
+
case 6:
|
|
1278
|
+
ary2cmatdouble(args[3], mdl_mtx, 4, 4);
|
|
1279
|
+
ary2cmatdouble(args[4], prj_mtx, 4, 4);
|
|
1280
|
+
ary2cint(args[5], vport, 4);
|
|
1281
|
+
break;
|
|
1282
|
+
default:
|
|
1283
|
+
rb_raise(rb_eArgError, "gluProject needs 3 or 6 parameters");
|
|
1284
|
+
}
|
|
1285
|
+
ox = (GLdouble)NUM2DBL(args[0]);
|
|
1286
|
+
oy = (GLdouble)NUM2DBL(args[1]);
|
|
1287
|
+
oz = (GLdouble)NUM2DBL(args[2]);
|
|
1288
|
+
|
|
1289
|
+
if (gluProject(ox, oy, oz, mdl_mtx, prj_mtx, vport, &wx, &wy, &wz) == GL_TRUE) {
|
|
1290
|
+
|
|
1291
|
+
return rb_ary_new3(3, rb_float_new(wx), rb_float_new(wy), rb_float_new(wz));
|
|
1292
|
+
} else {
|
|
1293
|
+
|
|
1294
|
+
check_for_gluerror(GLU_INVALID_VALUE);
|
|
1295
|
+
return Qnil; /* not reached */
|
|
1296
|
+
}
|
|
1293
1297
|
}
|
|
1294
1298
|
static VALUE
|
|
1295
1299
|
glu_UnProject(argc,argv,obj)
|
|
@@ -1297,238 +1301,238 @@ int argc;
|
|
|
1297
1301
|
VALUE* argv;
|
|
1298
1302
|
VALUE obj;
|
|
1299
1303
|
{
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1304
|
+
GLdouble wx;
|
|
1305
|
+
GLdouble wy;
|
|
1306
|
+
GLdouble wz;
|
|
1307
|
+
GLdouble mdl_mtx[4*4];
|
|
1308
|
+
GLdouble prj_mtx[4*4];
|
|
1309
|
+
GLint vport[4];
|
|
1310
|
+
GLdouble ox;
|
|
1311
|
+
GLdouble oy;
|
|
1312
|
+
GLdouble oz;
|
|
1313
|
+
|
|
1314
|
+
VALUE args[6];
|
|
1315
|
+
|
|
1316
|
+
switch (rb_scan_args(argc, argv, "33", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5])) {
|
|
1317
|
+
case 3:
|
|
1318
|
+
glGetDoublev(GL_MODELVIEW_MATRIX, mdl_mtx);
|
|
1319
|
+
glGetDoublev(GL_PROJECTION_MATRIX, prj_mtx);
|
|
1320
|
+
glGetIntegerv(GL_VIEWPORT, vport);
|
|
1321
|
+
break;
|
|
1322
|
+
case 6:
|
|
1323
|
+
ary2cmatdouble(args[3], mdl_mtx, 4, 4);
|
|
1324
|
+
ary2cmatdouble(args[4], prj_mtx, 4, 4);
|
|
1325
|
+
ary2cint(args[5], vport, 4);
|
|
1326
|
+
break;
|
|
1327
|
+
default:
|
|
1328
|
+
rb_raise(rb_eArgError, "gluUnProject needs 3 or 6 parameters");
|
|
1329
|
+
}
|
|
1330
|
+
wx = (GLdouble)NUM2DBL(args[0]);
|
|
1331
|
+
wy = (GLdouble)NUM2DBL(args[1]);
|
|
1332
|
+
wz = (GLdouble)NUM2DBL(args[2]);
|
|
1333
|
+
|
|
1334
|
+
if (gluUnProject(wx, wy, wz, mdl_mtx, prj_mtx, vport, &ox, &oy, &oz) == GL_TRUE) {
|
|
1335
|
+
|
|
1336
|
+
return rb_ary_new3(3, rb_float_new(ox), rb_float_new(oy), rb_float_new(oz));
|
|
1337
|
+
} else {
|
|
1338
|
+
|
|
1339
|
+
check_for_gluerror(GLU_INVALID_VALUE);
|
|
1340
|
+
return Qnil; /* not reached */
|
|
1341
|
+
}
|
|
1338
1342
|
}
|
|
1339
1343
|
|
|
1340
1344
|
static VALUE
|
|
1341
1345
|
glu_Build1DMipmaps(obj, arg1, arg2, arg3, arg4, arg5, arg6)
|
|
1342
1346
|
VALUE obj, arg1, arg2, arg3, arg4, arg5, arg6;
|
|
1343
1347
|
{
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1348
|
+
GLenum target;
|
|
1349
|
+
GLint components;
|
|
1350
|
+
GLint width;
|
|
1351
|
+
GLenum format;
|
|
1352
|
+
GLenum type;
|
|
1353
|
+
int ret;
|
|
1354
|
+
|
|
1355
|
+
target = (GLenum)NUM2INT(arg1);
|
|
1356
|
+
components = (GLint)NUM2INT(arg2);
|
|
1357
|
+
width = (GLint)NUM2INT(arg3);
|
|
1358
|
+
format = (GLenum)NUM2INT(arg4);
|
|
1359
|
+
type = (GLenum)NUM2INT(arg5);
|
|
1360
|
+
Check_Type(arg6,T_STRING);
|
|
1361
|
+
CheckDataSize(type,format,width,arg6);
|
|
1362
|
+
|
|
1363
|
+
ret = gluBuild1DMipmaps(target, components, width, format, type, RSTRING_PTR(arg6));
|
|
1364
|
+
check_for_gluerror(ret);
|
|
1365
|
+
|
|
1366
|
+
return INT2NUM(ret);
|
|
1363
1367
|
}
|
|
1364
1368
|
|
|
1365
1369
|
static VALUE
|
|
1366
1370
|
glu_Build2DMipmaps(obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
|
|
1367
1371
|
VALUE obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7;
|
|
1368
1372
|
{
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1373
|
+
GLenum target;
|
|
1374
|
+
GLint components;
|
|
1375
|
+
GLint width;
|
|
1376
|
+
GLint height;
|
|
1377
|
+
GLenum format;
|
|
1378
|
+
GLenum type;
|
|
1379
|
+
int ret;
|
|
1380
|
+
|
|
1381
|
+
target = (GLenum)NUM2INT(arg1);
|
|
1382
|
+
components = (GLint)NUM2INT(arg2);
|
|
1383
|
+
width = (GLint)NUM2INT(arg3);
|
|
1384
|
+
height = (GLint)NUM2INT(arg4);
|
|
1385
|
+
format = (GLenum)NUM2INT(arg5);
|
|
1386
|
+
type = (GLenum)NUM2INT(arg6);
|
|
1387
|
+
Check_Type(arg7,T_STRING);
|
|
1388
|
+
CheckDataSize(type,format,width*height,arg7);
|
|
1389
|
+
|
|
1390
|
+
ret = gluBuild2DMipmaps(target, components, width, height, format, type, RSTRING_PTR(arg7));
|
|
1391
|
+
check_for_gluerror(ret);
|
|
1392
|
+
|
|
1393
|
+
return INT2NUM(ret);
|
|
1390
1394
|
}
|
|
1391
1395
|
|
|
1392
1396
|
static VALUE
|
|
1393
1397
|
glu_ScaleImage(obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
|
|
1394
1398
|
VALUE obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8;
|
|
1395
1399
|
{
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1400
|
+
GLenum format;
|
|
1401
|
+
GLint widthin;
|
|
1402
|
+
GLint heightin;
|
|
1403
|
+
GLenum typein;
|
|
1404
|
+
void* datain;
|
|
1405
|
+
GLint widthout;
|
|
1406
|
+
GLint heightout;
|
|
1407
|
+
GLenum typeout;
|
|
1408
|
+
VALUE ret;
|
|
1409
|
+
GLint retcode;
|
|
1410
|
+
|
|
1411
|
+
format = (GLenum)NUM2INT(arg1);
|
|
1412
|
+
widthin = (GLint)NUM2INT(arg2);
|
|
1413
|
+
heightin = (GLint)NUM2INT(arg3);
|
|
1414
|
+
typein = (GLenum)NUM2INT(arg4);
|
|
1415
|
+
Check_Type(arg5,T_STRING);
|
|
1416
|
+
CheckDataSize(typein,format,heightin*widthin,arg5);
|
|
1417
|
+
datain = RSTRING_PTR(arg5);
|
|
1418
|
+
widthout = (GLint)NUM2INT(arg6);
|
|
1419
|
+
heightout = (GLint)NUM2INT(arg7);
|
|
1420
|
+
typeout = (GLenum)NUM2INT(arg8);
|
|
1421
|
+
ret = allocate_buffer_with_string(GetDataSize(typeout,format,widthout*heightout));
|
|
1422
|
+
retcode = gluScaleImage(format, widthin, heightin, typein, datain,
|
|
1423
|
+
widthout, heightout, typeout, (GLvoid*)RSTRING_PTR(ret));
|
|
1424
|
+
|
|
1425
|
+
check_for_gluerror(retcode);
|
|
1426
|
+
|
|
1427
|
+
return ret;
|
|
1424
1428
|
}
|
|
1425
1429
|
|
|
1426
1430
|
static VALUE
|
|
1427
1431
|
glu_ErrorString(obj, arg1)
|
|
1428
1432
|
VALUE obj, arg1;
|
|
1429
1433
|
{
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1434
|
+
GLenum errorCode;
|
|
1435
|
+
GLubyte* error;
|
|
1436
|
+
errorCode = (GLenum)NUM2INT(arg1);
|
|
1437
|
+
error = (GLubyte*)gluErrorString(errorCode);
|
|
1438
|
+
|
|
1439
|
+
if (error)
|
|
1440
|
+
return rb_str_new2((char *)error);
|
|
1441
|
+
else
|
|
1442
|
+
return Qnil;
|
|
1439
1443
|
}
|
|
1440
1444
|
static VALUE
|
|
1441
1445
|
glu_GetString(obj, arg1)
|
|
1442
1446
|
VALUE obj, arg1;
|
|
1443
1447
|
{
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1448
|
+
GLenum name;
|
|
1449
|
+
GLubyte* str;
|
|
1450
|
+
name = (GLenum)NUM2INT(arg1);
|
|
1451
|
+
str = (GLubyte*)gluGetString(name);
|
|
1452
|
+
|
|
1453
|
+
if (str)
|
|
1454
|
+
return rb_str_new2((char *)str);
|
|
1455
|
+
else
|
|
1456
|
+
return Qnil;
|
|
1453
1457
|
}
|
|
1454
1458
|
|
|
1455
1459
|
static VALUE module;
|
|
1456
1460
|
|
|
1457
1461
|
DLLEXPORT void Init_glu()
|
|
1458
1462
|
{
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1463
|
+
callId = rb_intern("call");
|
|
1464
|
+
refId = rb_intern("[]");
|
|
1465
|
+
module = rb_define_module("Glu");
|
|
1466
|
+
|
|
1467
|
+
glu_init_enums(module);
|
|
1468
|
+
|
|
1469
|
+
rb_define_module_function(module, "gluNewNurbsRenderer", glu_NewNurbsRenderer, 0);
|
|
1470
|
+
rb_define_module_function(module, "gluDeleteNurbsRenderer", glu_DeleteNurbsRenderer, 1);
|
|
1471
|
+
rb_define_module_function(module, "gluNurbsProperty", glu_NurbsProperty, 3);
|
|
1472
|
+
rb_define_module_function(module, "gluGetNurbsProperty", glu_GetNurbsProperty, 2);
|
|
1473
|
+
rb_define_module_function(module, "gluBeginCurve", glu_BeginCurve, 1);
|
|
1474
|
+
rb_define_module_function(module, "gluEndCurve", glu_EndCurve, 1);
|
|
1475
|
+
rb_define_module_function(module, "gluNurbsCurve", glu_NurbsCurve, -1);
|
|
1476
|
+
rb_define_module_function(module, "gluBeginSurface", glu_BeginSurface, 1);
|
|
1477
|
+
rb_define_module_function(module, "gluEndSurface", glu_EndSurface, 1);
|
|
1478
|
+
rb_define_module_function(module, "gluNurbsSurface", glu_NurbsSurface, -1);
|
|
1479
|
+
rb_define_module_function(module, "gluBeginTrim", glu_BeginTrim, 1);
|
|
1480
|
+
rb_define_module_function(module, "gluEndTrim", glu_EndTrim, 1);
|
|
1481
|
+
rb_define_module_function(module, "gluPwlCurve", glu_PwlCurve, -1);
|
|
1482
|
+
rb_define_module_function(module, "gluNewTess", glu_NewTess, 0);
|
|
1483
|
+
rb_define_module_function(module, "gluDeleteTess", glu_DeleteTess, 1);
|
|
1484
|
+
rb_define_module_function(module, "gluTessCallback", glu_TessCallback, 3);
|
|
1485
|
+
rb_define_module_function(module, "gluBeginPolygon", glu_BeginPolygon, 1);
|
|
1486
|
+
rb_define_module_function(module, "gluTessVertex", glu_TessVertex, 3);
|
|
1487
|
+
rb_define_module_function(module, "gluNextContour", glu_NextContour, 2);
|
|
1488
|
+
rb_define_module_function(module, "gluEndPolygon", glu_EndPolygon, 1);
|
|
1489
|
+
rb_define_module_function(module, "gluTessBeginPolygon", glu_TessBeginPolygon, 2);
|
|
1490
|
+
rb_define_module_function(module, "gluTessBeginContour", glu_TessBeginContour, 1);
|
|
1491
|
+
rb_define_module_function(module, "gluTessEndContour", glu_TessEndContour, 1);
|
|
1492
|
+
rb_define_module_function(module, "gluTessEndPolygon", glu_TessEndPolygon, 1);
|
|
1493
|
+
rb_define_module_function(module, "gluTessProperty", glu_TessProperty, 3);
|
|
1494
|
+
rb_define_module_function(module, "gluTessNormal", glu_TessNormal, 4);
|
|
1495
|
+
rb_define_module_function(module, "gluGetTessProperty", glu_GetTessProperty, 2);
|
|
1496
|
+
rb_define_module_function(module, "gluNewQuadric", glu_NewQuadric, 0);
|
|
1497
|
+
rb_define_module_function(module, "gluDeleteQuadric", glu_DeleteQuadric, 1);
|
|
1498
|
+
rb_define_module_function(module, "gluQuadricNormals", glu_QuadricNormals, 2);
|
|
1499
|
+
rb_define_module_function(module, "gluQuadricTexture", glu_QuadricTexture, 2);
|
|
1500
|
+
rb_define_module_function(module, "gluQuadricOrientation", glu_QuadricOrientation, 2);
|
|
1501
|
+
rb_define_module_function(module, "gluQuadricDrawStyle", glu_QuadricDrawStyle, 2);
|
|
1502
|
+
rb_define_module_function(module, "gluCylinder", glu_Cylinder, 6);
|
|
1503
|
+
rb_define_module_function(module, "gluDisk", glu_Disk, 5);
|
|
1504
|
+
rb_define_module_function(module, "gluPartialDisk", glu_PartialDisk, 7);
|
|
1505
|
+
rb_define_module_function(module, "gluSphere", glu_Sphere, 4);
|
|
1506
|
+
|
|
1507
|
+
rb_define_module_function(module, "gluLookAt", glu_LookAt, 9);
|
|
1508
|
+
rb_define_module_function(module, "gluOrtho2D", glu_Ortho2D, 4);
|
|
1509
|
+
rb_define_module_function(module, "gluPerspective", glu_Perspective, 4);
|
|
1510
|
+
rb_define_module_function(module, "gluPickMatrix", glu_PickMatrix, -1);
|
|
1511
|
+
rb_define_module_function(module, "gluProject", glu_Project, -1);
|
|
1512
|
+
rb_define_module_function(module, "gluUnProject", glu_UnProject, -1);
|
|
1513
|
+
rb_define_module_function(module, "gluBuild1DMipmaps", glu_Build1DMipmaps, 6);
|
|
1514
|
+
rb_define_module_function(module, "gluBuild2DMipmaps", glu_Build2DMipmaps, 7);
|
|
1515
|
+
rb_define_module_function(module, "gluScaleImage", glu_ScaleImage, 8);
|
|
1516
|
+
rb_define_module_function(module, "gluErrorString", glu_ErrorString, 1);
|
|
1517
|
+
rb_define_module_function(module, "gluGetString", glu_GetString, 1);
|
|
1518
|
+
|
|
1519
|
+
rb_define_module_function(module, "gluLoadSamplingMatrices",glu_LoadSamplingMatrices,4);
|
|
1520
|
+
rb_define_module_function(module, "gluQuadricCallback", glu_QuadricCallback, 3);
|
|
1521
|
+
rb_define_module_function(module, "gluNurbsCallback", glu_NurbsCallback, 3);
|
|
1522
|
+
|
|
1523
|
+
Class_GLUError = rb_define_class_under(module, "Error", rb_eStandardError);
|
|
1524
|
+
|
|
1525
|
+
rb_define_method(Class_GLUError, "initialize", GLUError_initialize, 2);
|
|
1526
|
+
rb_define_attr(Class_GLUError, "id", 1, 0);
|
|
1527
|
+
|
|
1528
|
+
cNurbs = rb_define_class("Nurbs", rb_cObject);
|
|
1529
|
+
cTess = rb_define_class("Tess", rb_cObject);
|
|
1530
|
+
cQuad = rb_define_class("Quadric", rb_cObject);
|
|
1531
|
+
|
|
1532
|
+
rb_global_variable(&t_current); /* current active tesselator, nurbs and quadric, used for callbacks */
|
|
1533
|
+
t_current = rb_ary_new();
|
|
1534
|
+
rb_global_variable(&n_current);
|
|
1535
|
+
n_current = rb_ary_new();
|
|
1536
|
+
rb_global_variable(&q_current);
|
|
1537
|
+
q_current = rb_ary_new();
|
|
1534
1538
|
}
|