ReactOS  0.4.15-dev-5496-g599ba9c
glcurveval.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  * glcurveval.c++
37  *
38  */
39 
40 /* Polynomial Evaluator Interface */
41 
42 #include "gluos.h"
43 //#include "glimports.h"
44 #include "glrenderer.h"
45 //#include "glcurveval.h"
46 //#include "nurbsconsts.h"
47 
49 {
50  //no default callback functions
51  beginCallBackN = NULL;
52  endCallBackN = NULL;
53  vertexCallBackN = NULL;
54  normalCallBackN = NULL;
55  colorCallBackN = NULL;
56  texcoordCallBackN = NULL;
57  beginCallBackData = NULL;
58  endCallBackData = NULL;
59  vertexCallBackData = NULL;
60  normalCallBackData = NULL;
61  colorCallBackData = NULL;
62  texcoordCallBackData = NULL;
63 
64  userData = NULL;
65 
66  vertex_flag = 0;
67  normal_flag = 0;
68  color_flag = 0;
69  texcoord_flag = 0;
70 
71  em_vertex.uprime = -1.0;
72  em_normal.uprime = -1.0;
73  em_color.uprime = -1.0;
74  em_texcoord.uprime = -1.0;
75  output_triangles = 0; // don't output triangles by default
76 }
77 
79 {
80 }
81 
82 /* added nonsense to avoid the warning messages at compile time */
83 void
85 {
86  m = m;
87 }
88 
89 void
91 {
92  type = type;
93  from = from;
94  to = to;
95 }
96 
97 void
99 {
100  ulo = ulo;
101  uhi = uhi;
102 }
103 
104 void
106 {
107  if(output_triangles)
109  else
111 }
112 
113 void
115 {
116  if(output_triangles)
118  else
119  glEnd();
120 }
121 
122 /*---------------------------------------------------------------------------
123  * disable - turn off a curve map
124  *---------------------------------------------------------------------------
125  */
126 void
128 {
129  glDisable((GLenum) type);
130 }
131 
132 /*---------------------------------------------------------------------------
133  * enable - turn on a curve map
134  *---------------------------------------------------------------------------
135  */
136 void
138 {
139  glEnable((GLenum) type);
140 }
141 
142 /*-------------------------------------------------------------------------
143  * mapgrid1f - define a lattice of points with origin and offset
144  *-------------------------------------------------------------------------
145  */
146 void
148 {
149  if(output_triangles)
150  {
151  global_grid_u0 = u0;
152  global_grid_u1 = u1;
153  global_grid_nu = (int) nu;
154  }
155  else
156  glMapGrid1f((GLint) nu, (GLfloat) u0, (GLfloat) u1);
157 }
158 
159 /*-------------------------------------------------------------------------
160  * bgnmap1 - preamble to curve definition and evaluations
161  *-------------------------------------------------------------------------
162  */
163 void
165 {
166  if(output_triangles)
167  {
168  //initialized so that no maps are set initially
169  vertex_flag = 0;
170  normal_flag = 0;
171  color_flag = 0;
172  texcoord_flag = 0;
173  //no need to worry about gl states when doing callback
174  }
175  else
177 }
178 
179 /*-------------------------------------------------------------------------
180  * endmap1 - postamble to a curve map
181  *-------------------------------------------------------------------------
182  */
183 void
185 {
186  if(output_triangles)
187  {
188 
189  }
190  else
191  glPopAttrib();
192 }
193 
194 /*-------------------------------------------------------------------------
195  * map1f - pass a desription of a curve map
196  *-------------------------------------------------------------------------
197  */
198 void
200  long type, /* map type */
201  REAL ulo, /* lower parametric bound */
202  REAL uhi, /* upper parametric bound */
203  long stride, /* distance to next point in REALS */
204  long order, /* parametric order */
205  REAL *pts /* control points */
206 )
207 {
208  if(output_triangles)
209  {
210  int dimension = 0;
211  int which = 0;
212  switch(type){
213  case GL_MAP1_VERTEX_3:
214  which = 0;
215  dimension = 3;
216  break;
217  case GL_MAP1_VERTEX_4:
218  which=0;
219  dimension = 4;
220  break;
221  case GL_MAP1_INDEX:
222  which=2;
223  dimension = 1;
224  break;
225  case GL_MAP1_COLOR_4:
226  which=2;
227  dimension = 4;
228  break;
229  case GL_MAP1_NORMAL:
230  which=1;
231  dimension = 3;
232  break;
234  which=3;
235  dimension = 1;
236  break;
238  which=3;
239  dimension = 2;
240  break;
241 
243  which=3;
244  dimension = 3;
245  break;
247  which=3;
248  dimension = 4;
249  break;
250  }
251  inMap1f(which, dimension, ulo, uhi, stride, order, pts);
252  }
253  else
254  glMap1f((GLenum) type, (GLfloat) ulo, (GLfloat) uhi, (GLint) stride,
255  (GLint) order, (const GLfloat *) pts);
256 }
257 
258 /*-------------------------------------------------------------------------
259  * mapmesh1f - evaluate a mesh of points on lattice
260  *-------------------------------------------------------------------------
261  */
262 void OpenGLCurveEvaluator::mapmesh1f(long style, long from, long to)
263 {
264  if(output_triangles)
265  {
266  inMapMesh1f((int) from, (int) to);
267  }
268  else
269  {
270  switch(style) {
271  default:
272  case N_MESHFILL:
273  case N_MESHLINE:
275  break;
276  case N_MESHPOINT:
278  break;
279  }
280  }
281 }
282 
283 /*-------------------------------------------------------------------------
284  * evalpoint1i - evaluate a point on a curve
285  *-------------------------------------------------------------------------
286  */
288 {
289  glEvalPoint1((GLint) i);
290 }
291 
292 /*-------------------------------------------------------------------------
293  * evalcoord1f - evaluate a point on a curve
294  *-------------------------------------------------------------------------
295  */
297 {
299 }
300 
301 void
302 #ifdef _WIN32
304 #else
306 #endif
307 {
308  switch(which)
309  {
310  case GLU_NURBS_BEGIN:
311  beginCallBackN = (void (GLAPIENTRY *) (GLenum)) fn;
312  break;
313  case GLU_NURBS_END:
314  endCallBackN = (void (GLAPIENTRY *) (void)) fn;
315  break;
316  case GLU_NURBS_VERTEX:
317  vertexCallBackN = (void (GLAPIENTRY *) (const GLfloat*)) fn;
318  break;
319  case GLU_NURBS_NORMAL:
320  normalCallBackN = (void (GLAPIENTRY *) (const GLfloat*)) fn;
321  break;
322  case GLU_NURBS_COLOR:
323  colorCallBackN = (void (GLAPIENTRY *) (const GLfloat*)) fn;
324  break;
326  texcoordCallBackN = (void (GLAPIENTRY *) (const GLfloat*)) fn;
327  break;
329  beginCallBackData = (void (GLAPIENTRY *) (GLenum, void*)) fn;
330  break;
331  case GLU_NURBS_END_DATA:
332  endCallBackData = (void (GLAPIENTRY *) (void*)) fn;
333  break;
335  vertexCallBackData = (void (GLAPIENTRY *) (const GLfloat*, void*)) fn;
336  break;
338  normalCallBackData = (void (GLAPIENTRY *) (const GLfloat*, void*)) fn;
339  break;
341  colorCallBackData = (void (GLAPIENTRY *) (const GLfloat*, void*)) fn;
342  break;
344  texcoordCallBackData = (void (GLAPIENTRY *) (const GLfloat*, void*)) fn;
345  break;
346  }
347 }
348 
349 void
351 {
352  if(beginCallBackData)
353  beginCallBackData(which, data);
354  else if(beginCallBackN)
355  beginCallBackN(which);
356 }
357 
358 void
360 {
361  if(endCallBackData)
362  endCallBackData(data);
363  else if(endCallBackN)
364  endCallBackN();
365 }
366 
367 void
369 {
370  if(vertexCallBackData)
371  vertexCallBackData(vert, data);
372  else if(vertexCallBackN)
373  vertexCallBackN(vert);
374 }
375 
376 
377 void
379 {
380  if(normalCallBackData)
381  normalCallBackData(normal, data);
382  else if(normalCallBackN)
383  normalCallBackN(normal);
384 }
385 
386 void
388 {
389  if(colorCallBackData)
390  colorCallBackData(color, data);
391  else if(colorCallBackN)
392  colorCallBackN(color);
393 }
394 
395 void
397 {
398  if(texcoordCallBackData)
399  texcoordCallBackData(texcoord, data);
400  else if(texcoordCallBackN)
401  texcoordCallBackN(texcoord);
402 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define GL_MAP1_VERTEX_4
Definition: gl.h:559
GLuint GLdouble GLdouble GLint GLint order
Definition: glext.h:11194
#define GLU_NURBS_NORMAL
Definition: glu.h:106
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
void mapgrid1f(long, REAL, REAL)
Definition: glcurveval.cc:147
void inMap1f(int which, int dimension, REAL ulower, REAL uupper, int ustride, int uorder, REAL *ctlpoints)
Definition: incurveeval.cc:90
#define GL_MAP1_COLOR_4
Definition: gl.h:551
#define GLU_NURBS_VERTEX
Definition: glu.h:104
void normalCallBack(const GLfloat *normal, void *data)
Definition: glcurveval.cc:378
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
static GLenum which
Definition: wgl_font.c:159
#define GL_MAP1_INDEX
Definition: gl.h:552
#define GL_EVAL_BIT
Definition: gl.h:718
void mapmesh1f(long, long, long)
Definition: glcurveval.cc:262
#define N_MESHPOINT
Definition: displaymode.h:38
void addMap(CurveMap *)
Definition: glcurveval.cc:84
GLdouble u1
Definition: glext.h:8308
void putCallBack(GLenum which, _GLUfuncptr fn)
Definition: glcurveval.cc:305
const GLfloat * m
Definition: glext.h:10848
void evalcoord1f(long, REAL)
Definition: glcurveval.cc:296
#define GL_MAP1_TEXTURE_COORD_2
Definition: gl.h:555
#define N_MESHLINE
Definition: displaymode.h:37
curveEvalMachine em_normal
Definition: glcurveval.h:103
GLAPI void GLAPIENTRY glMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points)
void vertexCallBack(const GLfloat *vert, void *data)
Definition: glcurveval.cc:368
GLuint color
Definition: glext.h:6243
#define GL_LINE
Definition: gl.h:266
GLAPI void GLAPIENTRY glPushAttrib(GLbitfield mask)
#define N_MESHFILL
Definition: displaymode.h:36
void colorCallBack(const GLfloat *color, void *data)
Definition: glcurveval.cc:387
#define GL_LINE_STRIP
Definition: gl.h:193
void range1f(long, REAL *, REAL *)
Definition: glcurveval.cc:90
virtual ~OpenGLCurveEvaluator(void)
Definition: glcurveval.cc:78
GLAPI void GLAPIENTRY glDisable(GLenum cap)
GLsizei stride
Definition: glext.h:5848
#define GL_MAP1_TEXTURE_COORD_3
Definition: gl.h:556
#define GL_MAP1_TEXTURE_COORD_1
Definition: gl.h:554
#define GL_MAP1_NORMAL
Definition: gl.h:553
unsigned int GLbitfield
Definition: gl.h:152
#define GLU_NURBS_END
Definition: glu.h:112
#define GL_POINT
Definition: gl.h:265
#define GL_MAP1_TEXTURE_COORD_4
Definition: gl.h:557
#define GLU_NURBS_BEGIN_DATA
Definition: glu.h:114
GLAPI void GLAPIENTRY glMapGrid1f(GLint un, GLfloat u1, GLfloat u2)
curveEvalMachine em_vertex
Definition: glcurveval.h:102
void inMapMesh1f(int umin, int umax)
Definition: incurveeval.cc:193
void endCallBack(void *data)
Definition: glcurveval.cc:359
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
void map1f(long, REAL, REAL, long, long, REAL *)
Definition: glcurveval.cc:199
void domain1f(REAL, REAL)
Definition: glcurveval.cc:98
void(WINAPI * _GLUfuncptr)(void)
Definition: wgl_font.c:148
GLAPI void GLAPIENTRY glBegin(GLenum mode)
#define GLU_NURBS_BEGIN
Definition: glu.h:102
void evalpoint1i(long)
Definition: glcurveval.cc:287
GLAPI void GLAPIENTRY glEnable(GLenum cap)
unsigned int GLenum
Definition: gl.h:150
GLAPI void GLAPIENTRY glEvalCoord1f(GLfloat u)
#define GLU_NURBS_COLOR
Definition: glu.h:108
#define GLU_NURBS_END_DATA
Definition: glu.h:124
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define GLU_NURBS_VERTEX_DATA
Definition: glu.h:116
#define GLU_NURBS_TEXTURE_COORD
Definition: glu.h:110
#define GLU_NURBS_COLOR_DATA
Definition: glu.h:120
#define GL_MAP1_VERTEX_3
Definition: gl.h:558
#define NULL
Definition: types.h:112
curveEvalMachine em_texcoord
Definition: glcurveval.h:105
GLAPI void GLAPIENTRY glEvalMesh1(GLenum mode, GLint i1, GLint i2)
float GLfloat
Definition: gl.h:161
void texcoordCallBack(const GLfloat *texcoord, void *data)
Definition: glcurveval.cc:396
curveEvalMachine em_color
Definition: glcurveval.h:104
GLAPI void GLAPIENTRY glEnd(void)
int GLint
Definition: gl.h:156
GLAPI void GLAPIENTRY glPopAttrib(void)
#define GLU_NURBS_TEXTURE_COORD_DATA
Definition: glu.h:122
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
float REAL
Definition: types.h:41
CardRegion * from
Definition: spigame.cpp:19
Arabic default style
Definition: afstyles.h:93
void beginCallBack(GLenum type, void *data)
Definition: glcurveval.cc:350
#define GLAPIENTRY
Definition: glu.h:44
#define GLU_NURBS_NORMAL_DATA
Definition: glu.h:118
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
GLAPI void GLAPIENTRY glEvalPoint1(GLint i)