41 #include <libnurbs2.h>
43 #include "glimports.h"
44 #include "glrenderer.h"
45 #include "nurbsconsts.h"
48 #ifdef DOWN_LOAD_NURBS
50 #include "oglTrimNurbs.h"
51 static int surfcount = 0;
52 static oglTrimNurbs* otn = NULL;
53 nurbSurf* tempNurb = NULL;
54 oglTrimLoops* tempTrim = NULL;
59 extern "C" {
void glu_LOD_eval_list(
GLUnurbs *nurb,
int level);}
61 void glu_LOD_eval_list(
GLUnurbs *nurb,
int level)
63 nurb->LOD_eval_list(level);
67 gluNewNurbsRenderer(
void)
92 #ifdef DOWN_LOAD_NURBS
94 tempTrim = OTL_make(10,10);
114 #ifdef DOWN_LOAD_NURBS
117 OTN_insert(otn, tempNurb, tempTrim);
121 printf(
"write file\n");
123 OTN_write(otn,
"out.otn");
134 #ifdef DOWN_LOAD_NURBS
135 OTL_bgnTrim(tempTrim);
144 #ifdef DOWN_LOAD_NURBS
145 OTL_endTrim(tempTrim);
151 gluPwlCurve(
GLUnurbs *r, GLint count, INREAL array[],
152 GLint stride, GLenum type)
154 #ifdef DOWN_LOAD_NURBS
155 OTL_pwlCurve(tempTrim, count, array, stride, type);
160 case GLU_MAP1_TRIM_2:
163 case GLU_MAP1_TRIM_3:
170 r->pwlcurve(count, array,
sizeof(INREAL) * stride, realType);
174 gluNurbsCurve(
GLUnurbs *r, GLint nknots, INREAL knot[], GLint stride,
175 INREAL ctlarray[], GLint order, GLenum type)
177 #ifdef DOWN_LOAD_NURBS
178 OTL_nurbsCurve(tempTrim, nknots, knot, stride, ctlarray, order, type);
184 case GLU_MAP1_TRIM_2:
187 case GLU_MAP1_TRIM_3:
195 r->nurbscurve(nknots, knot,
sizeof(INREAL) * stride, ctlarray, order,
200 gluNurbsSurface(
GLUnurbs *r, GLint sknot_count, GLfloat *sknot,
201 GLint tknot_count, GLfloat *tknot,
202 GLint s_stride, GLint t_stride,
203 GLfloat *ctlarray, GLint sorder, GLint torder,
206 #ifdef DOWN_LOAD_NURBS
210 case GL_MAP2_VERTEX_3:
213 case GL_MAP2_VERTEX_4:
217 fprintf(stderr,
"error in glinterface.c++, type no implemented\n");
220 tempNurb = nurbSurfMake(sknot_count, sknot,
230 r->nurbssurface(sknot_count, sknot, tknot_count, tknot,
231 sizeof(INREAL) * s_stride,
sizeof(INREAL) * t_stride,
232 ctlarray, sorder, torder, type);
236 gluLoadSamplingMatrices(
GLUnurbs *r,
const GLfloat modelMatrix[16],
237 const GLfloat projMatrix[16],
238 const GLint viewport[4])
240 r->useGLMatrices(modelMatrix, projMatrix, viewport);
244 gluNurbsProperty(
GLUnurbs *r, GLenum property, GLfloat value)
249 case GLU_AUTO_LOAD_MATRIX:
250 r->setautoloadmode(value);
255 nurbsValue = N_CULLINGON;
257 nurbsValue = N_NOCULLING;
259 r->setnurbsproperty(GL_MAP2_VERTEX_3, N_CULLING, nurbsValue);
260 r->setnurbsproperty(GL_MAP2_VERTEX_4, N_CULLING, nurbsValue);
261 r->setnurbsproperty(GL_MAP1_VERTEX_3, N_CULLING, nurbsValue);
262 r->setnurbsproperty(GL_MAP1_VERTEX_4, N_CULLING, nurbsValue);
265 case GLU_SAMPLING_METHOD:
266 if (value == GLU_PATH_LENGTH) {
267 nurbsValue = N_PATHLENGTH;
268 }
else if (value == GLU_PARAMETRIC_ERROR) {
269 nurbsValue = N_PARAMETRICDISTANCE;
270 }
else if (value == GLU_DOMAIN_DISTANCE) {
271 nurbsValue = N_DOMAINDISTANCE;
272 r->set_is_domain_distance_sampling(1);
274 }
else if (value == GLU_OBJECT_PARAMETRIC_ERROR) {
275 nurbsValue = N_OBJECTSPACE_PARA;
276 r->setautoloadmode( 0.0 );
277 r->setSamplingMatrixIdentity();
278 }
else if (value == GLU_OBJECT_PATH_LENGTH) {
279 nurbsValue = N_OBJECTSPACE_PATH;
280 r->setautoloadmode( 0.0 );
281 r->setSamplingMatrixIdentity();
283 r->postError(GLU_INVALID_VALUE);
287 r->setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMETHOD, nurbsValue);
288 r->setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMETHOD, nurbsValue);
289 r->setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMETHOD, nurbsValue);
290 r->setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMETHOD, nurbsValue);
293 case GLU_SAMPLING_TOLERANCE:
294 r->setnurbsproperty(GL_MAP2_VERTEX_3, N_PIXEL_TOLERANCE, value);
295 r->setnurbsproperty(GL_MAP2_VERTEX_4, N_PIXEL_TOLERANCE, value);
296 r->setnurbsproperty(GL_MAP1_VERTEX_3, N_PIXEL_TOLERANCE, value);
297 r->setnurbsproperty(GL_MAP1_VERTEX_4, N_PIXEL_TOLERANCE, value);
300 case GLU_PARAMETRIC_TOLERANCE:
301 r->setnurbsproperty(GL_MAP2_VERTEX_3, N_ERROR_TOLERANCE, value);
302 r->setnurbsproperty(GL_MAP2_VERTEX_4, N_ERROR_TOLERANCE, value);
303 r->setnurbsproperty(GL_MAP1_VERTEX_3, N_ERROR_TOLERANCE, value);
304 r->setnurbsproperty(GL_MAP1_VERTEX_4, N_ERROR_TOLERANCE, value);
308 case GLU_DISPLAY_MODE:
310 if (value == GLU_FILL) {
312 }
else if (value == GLU_OUTLINE_POLYGON) {
313 nurbsValue = N_OUTLINE_POLY;
314 }
else if (value == GLU_OUTLINE_PATCH) {
315 nurbsValue = N_OUTLINE_PATCH;
317 r->postError(GLU_INVALID_VALUE);
320 r->setnurbsproperty(N_DISPLAY, nurbsValue);
325 r->setnurbsproperty(GL_MAP1_VERTEX_3, N_S_STEPS, value);
326 r->setnurbsproperty(GL_MAP1_VERTEX_4, N_S_STEPS, value);
327 r->setnurbsproperty(GL_MAP2_VERTEX_3, N_S_STEPS, value);
328 r->setnurbsproperty(GL_MAP2_VERTEX_4, N_S_STEPS, value);
331 r->set_domain_distance_u_rate(value);
335 r->setnurbsproperty(GL_MAP1_VERTEX_3, N_T_STEPS, value);
336 r->setnurbsproperty(GL_MAP1_VERTEX_4, N_T_STEPS, value);
337 r->setnurbsproperty(GL_MAP2_VERTEX_3, N_T_STEPS, value);
338 r->setnurbsproperty(GL_MAP2_VERTEX_4, N_T_STEPS, value);
341 r->set_domain_distance_v_rate(value);
345 if(value == GLU_NURBS_RENDERER)
346 r->put_callbackFlag(0);
347 else if(value == GLU_NURBS_TESSELLATOR)
348 r->put_callbackFlag(1);
350 r->postError(GLU_INVALID_ENUM);
354 r->postError(GLU_INVALID_ENUM);
360 gluGetNurbsProperty(
GLUnurbs *r, GLenum property, GLfloat *value)
365 case GLU_AUTO_LOAD_MATRIX:
366 if (r->getautoloadmode()) {
373 r->getnurbsproperty(GL_MAP2_VERTEX_3, N_CULLING, &nurbsValue);
374 if (nurbsValue == N_CULLINGON) {
380 case GLU_SAMPLING_METHOD:
381 r->getnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMETHOD, value);
382 if(*value == N_PATHLENGTH)
383 *value = GLU_PATH_LENGTH;
384 else if(*value == N_PARAMETRICDISTANCE)
385 *value = GLU_PARAMETRIC_ERROR;
386 else if(*value == N_DOMAINDISTANCE)
387 *value = GLU_DOMAIN_DISTANCE;
388 else if(*value == N_OBJECTSPACE_PATH)
389 *value = GLU_OBJECT_PATH_LENGTH;
390 else if(*value == N_OBJECTSPACE_PARA)
391 *value = GLU_OBJECT_PARAMETRIC_ERROR;
393 case GLU_SAMPLING_TOLERANCE:
394 r->getnurbsproperty(GL_MAP2_VERTEX_3, N_PIXEL_TOLERANCE, value);
396 case GLU_PARAMETRIC_TOLERANCE:
397 r->getnurbsproperty(GL_MAP2_VERTEX_3, N_ERROR_TOLERANCE, value);
401 r->getnurbsproperty(GL_MAP2_VERTEX_3, N_S_STEPS, value);
404 r->getnurbsproperty(GL_MAP2_VERTEX_3, N_T_STEPS, value);
406 case GLU_DISPLAY_MODE:
407 r->getnurbsproperty(N_DISPLAY, &nurbsValue);
408 if (nurbsValue == N_FILL) {
410 }
else if (nurbsValue == N_OUTLINE_POLY) {
411 *value = GLU_OUTLINE_POLYGON;
413 *value = GLU_OUTLINE_PATCH;
419 *value = GLU_NURBS_TESSELLATOR;
421 *value = GLU_NURBS_RENDERER;
425 r->postError(GLU_INVALID_ENUM);
430 extern "C" void GLAPIENTRY
431 gluNurbsCallback(
GLUnurbs *r, GLenum which, _GLUfuncptr fn )
434 case GLU_NURBS_BEGIN:
436 case GLU_NURBS_VERTEX:
437 case GLU_NURBS_NORMAL:
438 case GLU_NURBS_TEXTURE_COORD:
439 case GLU_NURBS_COLOR:
440 case GLU_NURBS_BEGIN_DATA:
441 case GLU_NURBS_END_DATA:
442 case GLU_NURBS_VERTEX_DATA:
443 case GLU_NURBS_NORMAL_DATA:
444 case GLU_NURBS_TEXTURE_COORD_DATA:
445 case GLU_NURBS_COLOR_DATA:
446 r->putSurfCallBack(which, fn);
449 case GLU_NURBS_ERROR:
450 r->errorCallback = (void (APIENTRY *)( GLenum e )) fn;
453 r->postError(GLU_INVALID_ENUM);
460 gluNurbsCallbackDataEXT(
GLUnurbs* r,
void* userData)
462 r->setNurbsCallbackData(userData);
467 gluNurbsCallbackData(
GLUnurbs* r,
void* userData)
469 gluNurbsCallbackDataEXT(r,userData);