ReactOS 0.4.15-dev-7674-gc0b4db1
glinterface.cc
Go to the documentation of this file.
1/*
2** License Applicability. Except to the extent portions of this file are
3** made subject to an alternative license as permitted in the SGI Free
4** Software License B, Version 1.1 (the "License"), the contents of this
5** file are subject only to the provisions of the License. You may not use
6** this file except in compliance with the License. You may obtain a copy
7** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
8** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
9**
10** http://oss.sgi.com/projects/FreeB
11**
12** Note that, as provided in the License, the Software is distributed on an
13** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
14** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
15** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
16** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
17**
18** Original Code. The Original Code is: OpenGL Sample Implementation,
19** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
20** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
21** Copyright in any portions created by third parties is as indicated
22** elsewhere herein. All Rights Reserved.
23**
24** Additional Notice Provisions: The application programming interfaces
25** established by SGI in conjunction with the Original Code are The
26** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
27** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
28** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
29** Window System(R) (Version 1.3), released October 19, 1998. This software
30** was created using the OpenGL(R) version 1.2.1 Sample Implementation
31** published by SGI, but has not been independently verified as being
32** compliant with the OpenGL(R) version 1.2.1 Specification.
33**
34*/
35/*
36*/
37
38#include "gluos.h"
39//#include <GL/gl.h>
40//#include <GL/glu.h>
41//#include <stdio.h>
42//#include "glimports.h"
43#include "glrenderer.h"
44//#include "nurbsconsts.h"
45
46//#define DOWN_LOAD_NURBS
47#ifdef DOWN_LOAD_NURBS
48
49#include "oglTrimNurbs.h"
50static int surfcount = 0;
51static oglTrimNurbs* otn = NULL;
52nurbSurf* tempNurb = NULL;
53oglTrimLoops* tempTrim = NULL;
54#endif
55
56
57//for LOD
58extern "C" {void glu_LOD_eval_list(GLUnurbs *nurb, int level);}
59
61{
62 nurb->LOD_eval_list(level);
63}
64
67{
68 GLUnurbs *t;
69
70 t = new GLUnurbs();
71 return t;
72}
73
74void GLAPIENTRY
76{
77 delete r;
78}
79
80extern "C"
81void GLAPIENTRY
82
84{
85 delete r;
86}
87
88void GLAPIENTRY
90{
91#ifdef DOWN_LOAD_NURBS
92surfcount++;
93tempTrim = OTL_make(10,10);
94#endif
95 r->bgnsurface(0);
96}
97
98void GLAPIENTRY
100{
101 r->bgncurve(0);
102}
103
104void GLAPIENTRY
106{
107 r->endcurve();
108}
109
110void GLAPIENTRY
112{
113#ifdef DOWN_LOAD_NURBS
114if(surfcount == 1)
115 otn = OTN_make(1);
116OTN_insert(otn, tempNurb, tempTrim);
117if(surfcount >= 1)
118{
119#ifdef DEBUG
120printf("write file\n");
121#endif
122OTN_write(otn, "out.otn");
123
124}
125#endif
126
127 r->endsurface();
128}
129
130void GLAPIENTRY
132{
133#ifdef DOWN_LOAD_NURBS
134OTL_bgnTrim(tempTrim);
135#endif
136
137 r->bgntrim();
138}
139
140void GLAPIENTRY
142{
143#ifdef DOWN_LOAD_NURBS
144OTL_endTrim(tempTrim);
145#endif
146 r->endtrim();
147}
148
149void GLAPIENTRY
152{
153#ifdef DOWN_LOAD_NURBS
154OTL_pwlCurve(tempTrim, count, array, stride, type);
155#endif
156
157 int realType;
158 switch(type) {
159 case GLU_MAP1_TRIM_2:
160 realType = N_P2D;
161 break;
162 case GLU_MAP1_TRIM_3:
163 realType = N_P2DR;
164 break;
165 default:
166 realType = type;
167 break;
168 }
169 r->pwlcurve(count, array, sizeof(INREAL) * stride, realType);
170}
171
172void GLAPIENTRY
174 INREAL ctlarray[], GLint order, GLenum type)
175{
176#ifdef DOWN_LOAD_NURBS
177OTL_nurbsCurve(tempTrim, nknots, knot, stride, ctlarray, order, type);
178#endif
179
180 int realType;
181
182 switch(type) {
183 case GLU_MAP1_TRIM_2:
184 realType = N_P2D;
185 break;
186 case GLU_MAP1_TRIM_3:
187 realType = N_P2DR;
188 break;
189 default:
190 realType = type;
191 break;
192 }
193
194 r->nurbscurve(nknots, knot, sizeof(INREAL) * stride, ctlarray, order,
195 realType);
196}
197
198void GLAPIENTRY
199gluNurbsSurface(GLUnurbs *r, GLint sknot_count, GLfloat *sknot,
200 GLint tknot_count, GLfloat *tknot,
201 GLint s_stride, GLint t_stride,
202 GLfloat *ctlarray, GLint sorder, GLint torder,
203 GLenum type)
204{
205#ifdef DOWN_LOAD_NURBS
206 {
207 int dimension;
208 switch(type){
209 case GL_MAP2_VERTEX_3:
210 dimension = 3;
211 break;
212 case GL_MAP2_VERTEX_4:
213 dimension = 4;
214 break;
215 default:
216 fprintf(stderr, "error in glinterface.c++, type no implemented\n");
217 exit(1);
218 }
219tempNurb = nurbSurfMake(sknot_count, sknot,
220 tknot_count, tknot,
221 sorder, torder,
222 dimension,
223 ctlarray,
224 s_stride, t_stride);
225
226 }
227#endif
228
229 r->nurbssurface(sknot_count, sknot, tknot_count, tknot,
230 sizeof(INREAL) * s_stride, sizeof(INREAL) * t_stride,
231 ctlarray, sorder, torder, type);
232}
233
234void GLAPIENTRY
236 const GLfloat projMatrix[16],
237 const GLint viewport[4])
238{
239 r->useGLMatrices(modelMatrix, projMatrix, viewport);
240}
241
242void GLAPIENTRY
244{
245 GLfloat nurbsValue;
246
247 switch (property) {
249 r->setautoloadmode(value);
250 return;
251
252 case GLU_CULLING:
253 if (value != 0.0) {
254 nurbsValue = N_CULLINGON;
255 } else {
256 nurbsValue = N_NOCULLING;
257 }
258 r->setnurbsproperty(GL_MAP2_VERTEX_3, N_CULLING, nurbsValue);
259 r->setnurbsproperty(GL_MAP2_VERTEX_4, N_CULLING, nurbsValue);
260 r->setnurbsproperty(GL_MAP1_VERTEX_3, N_CULLING, nurbsValue);
261 r->setnurbsproperty(GL_MAP1_VERTEX_4, N_CULLING, nurbsValue);
262 return;
263
265 if (value == GLU_PATH_LENGTH) {
266 nurbsValue = N_PATHLENGTH;
267 } else if (value == GLU_PARAMETRIC_ERROR) {
268 nurbsValue = N_PARAMETRICDISTANCE;
269 } else if (value == GLU_DOMAIN_DISTANCE) {
270 nurbsValue = N_DOMAINDISTANCE;
271 r->set_is_domain_distance_sampling(1); //optimzing untrimmed case
272
273 } else if (value == GLU_OBJECT_PARAMETRIC_ERROR) {
274 nurbsValue = N_OBJECTSPACE_PARA;
275 r->setautoloadmode( 0.0 );
276 r->setSamplingMatrixIdentity();
277 } else if (value == GLU_OBJECT_PATH_LENGTH) {
278 nurbsValue = N_OBJECTSPACE_PATH;
279 r->setautoloadmode( 0.0 );
280 r->setSamplingMatrixIdentity();
281 } else {
282 r->postError(GLU_INVALID_VALUE);
283 return;
284 }
285
286 r->setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMETHOD, nurbsValue);
287 r->setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMETHOD, nurbsValue);
288 r->setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMETHOD, nurbsValue);
289 r->setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMETHOD, nurbsValue);
290 return;
291
293 r->setnurbsproperty(GL_MAP2_VERTEX_3, N_PIXEL_TOLERANCE, value);
294 r->setnurbsproperty(GL_MAP2_VERTEX_4, N_PIXEL_TOLERANCE, value);
295 r->setnurbsproperty(GL_MAP1_VERTEX_3, N_PIXEL_TOLERANCE, value);
296 r->setnurbsproperty(GL_MAP1_VERTEX_4, N_PIXEL_TOLERANCE, value);
297 return;
298
300 r->setnurbsproperty(GL_MAP2_VERTEX_3, N_ERROR_TOLERANCE, value);
301 r->setnurbsproperty(GL_MAP2_VERTEX_4, N_ERROR_TOLERANCE, value);
302 r->setnurbsproperty(GL_MAP1_VERTEX_3, N_ERROR_TOLERANCE, value);
303 r->setnurbsproperty(GL_MAP1_VERTEX_4, N_ERROR_TOLERANCE, value);
304 return;
305
306
307 case GLU_DISPLAY_MODE:
308
309 if (value == GLU_FILL) {
310 nurbsValue = N_FILL;
311 } else if (value == GLU_OUTLINE_POLYGON) {
312 nurbsValue = N_OUTLINE_POLY;
313 } else if (value == GLU_OUTLINE_PATCH) {
314 nurbsValue = N_OUTLINE_PATCH;
315 } else {
316 r->postError(GLU_INVALID_VALUE);
317 return;
318 }
319 r->setnurbsproperty(N_DISPLAY, nurbsValue);
320
321 break;
322
323 case GLU_U_STEP:
324 r->setnurbsproperty(GL_MAP1_VERTEX_3, N_S_STEPS, value);
325 r->setnurbsproperty(GL_MAP1_VERTEX_4, N_S_STEPS, value);
326 r->setnurbsproperty(GL_MAP2_VERTEX_3, N_S_STEPS, value);
327 r->setnurbsproperty(GL_MAP2_VERTEX_4, N_S_STEPS, value);
328
329 //added for optimizing untrimmed case
330 r->set_domain_distance_u_rate(value);
331 break;
332
333 case GLU_V_STEP:
334 r->setnurbsproperty(GL_MAP1_VERTEX_3, N_T_STEPS, value);
335 r->setnurbsproperty(GL_MAP1_VERTEX_4, N_T_STEPS, value);
336 r->setnurbsproperty(GL_MAP2_VERTEX_3, N_T_STEPS, value);
337 r->setnurbsproperty(GL_MAP2_VERTEX_4, N_T_STEPS, value);
338
339 //added for optimizing untrimmed case
340 r->set_domain_distance_v_rate(value);
341 break;
342
343 case GLU_NURBS_MODE:
345 r->put_callbackFlag(0);
346 else if(value == GLU_NURBS_TESSELLATOR)
347 r->put_callbackFlag(1);
348 else
349 r->postError(GLU_INVALID_ENUM);
350 break;
351
352 default:
353 r->postError(GLU_INVALID_ENUM);
354 return;
355 }
356}
357
358void GLAPIENTRY
360{
361 GLfloat nurbsValue;
362
363 switch(property) {
365 if (r->getautoloadmode()) {
366 *value = GL_TRUE;
367 } else {
368 *value = GL_FALSE;
369 }
370 break;
371 case GLU_CULLING:
372 r->getnurbsproperty(GL_MAP2_VERTEX_3, N_CULLING, &nurbsValue);
373 if (nurbsValue == N_CULLINGON) {
374 *value = GL_TRUE;
375 } else {
376 *value = GL_FALSE;
377 }
378 break;
380 r->getnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMETHOD, value);
381 if(*value == N_PATHLENGTH)
383 else if(*value == N_PARAMETRICDISTANCE)
385 else if(*value == N_DOMAINDISTANCE)
387 else if(*value == N_OBJECTSPACE_PATH)
389 else if(*value == N_OBJECTSPACE_PARA)
391 break;
393 r->getnurbsproperty(GL_MAP2_VERTEX_3, N_PIXEL_TOLERANCE, value);
394 break;
396 r->getnurbsproperty(GL_MAP2_VERTEX_3, N_ERROR_TOLERANCE, value);
397 break;
398
399 case GLU_U_STEP:
400 r->getnurbsproperty(GL_MAP2_VERTEX_3, N_S_STEPS, value);
401 break;
402 case GLU_V_STEP:
403 r->getnurbsproperty(GL_MAP2_VERTEX_3, N_T_STEPS, value);
404 break;
405 case GLU_DISPLAY_MODE:
406 r->getnurbsproperty(N_DISPLAY, &nurbsValue);
407 if (nurbsValue == N_FILL) {
408 *value = GLU_FILL;
409 } else if (nurbsValue == N_OUTLINE_POLY) {
411 } else {
413 }
414 break;
415
416 case GLU_NURBS_MODE:
417 if(r->is_callback())
419 else
421 break;
422
423 default:
424 r->postError(GLU_INVALID_ENUM);
425 return;
426 }
427}
428
429extern "C" void GLAPIENTRY
431{
432 switch (which) {
433 case GLU_NURBS_BEGIN:
434 case GLU_NURBS_END:
435 case GLU_NURBS_VERTEX:
436 case GLU_NURBS_NORMAL:
438 case GLU_NURBS_COLOR:
445 r->putSurfCallBack(which, fn);
446 break;
447
448 case GLU_NURBS_ERROR:
449 r->errorCallback = (void (APIENTRY *)( GLenum e )) fn;
450 break;
451 default:
452 r->postError(GLU_INVALID_ENUM);
453 return;
454 }
455}
456
457extern "C"
458void GLAPIENTRY
460{
461 r->setNurbsCallbackData(userData);
462}
463
464extern "C"
465void GLAPIENTRY
467{
468 gluNurbsCallbackDataEXT(r,userData);
469}
void LOD_eval_list(int level)
Definition: glrenderer.h:112
#define NULL
Definition: types.h:112
#define GLU_PATH_LENGTH
Definition: glu.h:187
#define GLU_NURBS_END
Definition: glu.h:112
#define GLU_INVALID_ENUM
Definition: glu.h:88
#define GLU_OUTLINE_PATCH
Definition: glu.h:97
#define GLU_NURBS_ERROR
Definition: glu.h:100
#define GLU_AUTO_LOAD_MATRIX
Definition: glu.h:167
#define GLU_NURBS_RENDERER
Definition: glu.h:179
#define GLU_SAMPLING_TOLERANCE
Definition: glu.h:169
#define GLU_MAP1_TRIM_3
Definition: glu.h:193
#define GLU_NURBS_NORMAL
Definition: glu.h:106
#define GLU_OBJECT_PARAMETRIC_ERROR
Definition: glu.h:183
#define GLU_NURBS_COLOR
Definition: glu.h:108
#define GLU_NURBS_TEXTURE_COORD
Definition: glu.h:110
#define GLU_OBJECT_PATH_LENGTH
Definition: glu.h:185
#define GLU_NURBS_VERTEX_DATA
Definition: glu.h:116
#define GLU_U_STEP
Definition: glu.h:173
#define GLU_DISPLAY_MODE
Definition: glu.h:170
#define GLU_DOMAIN_DISTANCE
Definition: glu.h:189
#define GLU_CULLING
Definition: glu.h:168
#define GLU_NURBS_TEXTURE_COORD_DATA
Definition: glu.h:122
#define GLU_NURBS_VERTEX
Definition: glu.h:104
#define GLAPIENTRY
Definition: glu.h:44
#define GLU_V_STEP
Definition: glu.h:174
#define GLU_NURBS_MODE
Definition: glu.h:175
#define GLU_NURBS_COLOR_DATA
Definition: glu.h:120
#define GLU_OUTLINE_POLYGON
Definition: glu.h:96
#define GLU_PARAMETRIC_ERROR
Definition: glu.h:188
#define GLU_FILL
Definition: glu.h:198
#define GLU_NURBS_BEGIN_DATA
Definition: glu.h:114
#define GLU_PARAMETRIC_TOLERANCE
Definition: glu.h:171
#define GLU_MAP1_TRIM_2
Definition: glu.h:192
#define GLU_NURBS_END_DATA
Definition: glu.h:124
#define GLU_NURBS_TESSELLATOR
Definition: glu.h:177
#define GLU_NURBS_BEGIN
Definition: glu.h:102
#define GLU_NURBS_NORMAL_DATA
Definition: glu.h:118
#define GLU_SAMPLING_METHOD
Definition: glu.h:172
#define GLU_INVALID_VALUE
Definition: glu.h:89
#define INREAL
Definition: types.h:40
#define APIENTRY
Definition: api.h:79
#define printf
Definition: freeldr.h:94
#define GL_TRUE
Definition: gl.h:174
GLint level
Definition: gl.h:1546
#define GL_MAP1_VERTEX_3
Definition: gl.h:558
float GLfloat
Definition: gl.h:161
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
unsigned int GLenum
Definition: gl.h:150
#define GL_MAP2_VERTEX_4
Definition: gl.h:568
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define GL_MAP2_VERTEX_3
Definition: gl.h:567
#define GL_FALSE
Definition: gl.h:173
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble GLdouble t
Definition: gl.h:2047
int GLint
Definition: gl.h:156
#define GL_MAP1_VERTEX_4
Definition: gl.h:559
GLsizei stride
Definition: glext.h:5848
GLuint GLdouble GLdouble GLint GLint order
Definition: glext.h:11194
void GLAPIENTRY gluDeleteNurbsTessellatorEXT(GLUnurbsObj *r)
Definition: glinterface.cc:83
void glu_LOD_eval_list(GLUnurbs *nurb, int level)
Definition: glinterface.cc:60
GLUnurbs *GLAPIENTRY gluNewNurbsRenderer(void)
Definition: glinterface.cc:66
#define gluNurbsSurface
Definition: glu_mangle.h:57
#define gluEndCurve
Definition: glu_mangle.h:53
#define gluLoadSamplingMatrices
Definition: glu_mangle.h:49
#define gluNurbsCallbackDataEXT
Definition: glu_mangle.h:84
#define gluBeginSurface
Definition: glu_mangle.h:55
#define gluDeleteNurbsRenderer
Definition: glu_mangle.h:48
#define gluNurbsCurve
Definition: glu_mangle.h:54
#define gluNurbsCallback
Definition: glu_mangle.h:61
#define gluBeginCurve
Definition: glu_mangle.h:52
#define gluEndSurface
Definition: glu_mangle.h:56
#define gluGetNurbsProperty
Definition: glu_mangle.h:51
#define gluNurbsProperty
Definition: glu_mangle.h:50
#define gluPwlCurve
Definition: glu_mangle.h:60
#define gluNurbsCallbackData
Definition: glu_mangle.h:83
#define gluEndTrim
Definition: glu_mangle.h:59
#define gluBeginTrim
Definition: glu_mangle.h:58
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define e
Definition: ke_i.h:82
#define N_CULLINGON
Definition: nurbsconsts.h:53
#define N_OUTLINE_PATCH
Definition: nurbsconsts.h:75
#define N_DISPLAY
Definition: nurbsconsts.h:70
#define N_PATHLENGTH
Definition: nurbsconsts.h:59
#define N_OUTLINE_POLY
Definition: nurbsconsts.h:72
#define N_S_STEPS
Definition: nurbsconsts.h:99
#define N_OBJECTSPACE_PARA
Definition: nurbsconsts.h:61
#define N_T_STEPS
Definition: nurbsconsts.h:100
#define N_OBJECTSPACE_PATH
Definition: nurbsconsts.h:62
#define N_PIXEL_TOLERANCE
Definition: nurbsconsts.h:89
#define N_P2D
Definition: nurbsconsts.h:116
#define N_FILL
Definition: nurbsconsts.h:71
#define N_PARAMETRICDISTANCE
Definition: nurbsconsts.h:58
#define N_P2DR
Definition: nurbsconsts.h:117
#define N_ERROR_TOLERANCE
Definition: nurbsconsts.h:90
#define N_SAMPLINGMETHOD
Definition: nurbsconsts.h:54
#define N_DOMAINDISTANCE
Definition: nurbsconsts.h:57
#define N_CULLING
Definition: nurbsconsts.h:51
#define N_NOCULLING
Definition: nurbsconsts.h:52
#define exit(n)
Definition: config.h:202
Definition: pdh_main.c:94
static GLenum which
Definition: wgl_font.c:159
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
void(WINAPI * _GLUfuncptr)(void)
Definition: wgl_font.c:148