ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

glcurveval.cc
Go to the documentation of this file.
00001 /*
00002 ** License Applicability. Except to the extent portions of this file are
00003 ** made subject to an alternative license as permitted in the SGI Free
00004 ** Software License B, Version 1.1 (the "License"), the contents of this
00005 ** file are subject only to the provisions of the License. You may not use
00006 ** this file except in compliance with the License. You may obtain a copy
00007 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
00008 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
00009 **
00010 ** http://oss.sgi.com/projects/FreeB
00011 **
00012 ** Note that, as provided in the License, the Software is distributed on an
00013 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
00014 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
00015 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
00016 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
00017 **
00018 ** Original Code. The Original Code is: OpenGL Sample Implementation,
00019 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
00020 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
00021 ** Copyright in any portions created by third parties is as indicated
00022 ** elsewhere herein. All Rights Reserved.
00023 **
00024 ** Additional Notice Provisions: The application programming interfaces
00025 ** established by SGI in conjunction with the Original Code are The
00026 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
00027 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
00028 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
00029 ** Window System(R) (Version 1.3), released October 19, 1998. This software
00030 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
00031 ** published by SGI, but has not been independently verified as being
00032 ** compliant with the OpenGL(R) version 1.2.1 Specification.
00033 */
00034 
00035 /*
00036  * glcurveval.c++
00037  *
00038  * $Date: 2006-03-12 00:07:02 +0000 (Sun, 12 Mar 2006) $ $Revision: 1.1 $
00039  * $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/lib/glu32/libnurbs/interface/glcurveval.cc,v 1.1 2004/02/02 16:39:08 navaraf Exp $
00040  */
00041 
00042 /* Polynomial Evaluator Interface */
00043 
00044 #include "gluos.h"
00045 #include "glimports.h"
00046 #include "glrenderer.h"
00047 #include "glcurveval.h"
00048 #include "nurbsconsts.h"
00049  
00050 OpenGLCurveEvaluator::OpenGLCurveEvaluator(void) 
00051 {
00052   //no default callback functions
00053   beginCallBackN = NULL;
00054   endCallBackN = NULL;
00055   vertexCallBackN = NULL;
00056   normalCallBackN = NULL;
00057   colorCallBackN = NULL;
00058   texcoordCallBackN = NULL;
00059   beginCallBackData = NULL;
00060   endCallBackData = NULL;
00061   vertexCallBackData = NULL;
00062   normalCallBackData = NULL;
00063   colorCallBackData = NULL;
00064   texcoordCallBackData = NULL;
00065 
00066   userData = NULL;
00067   
00068   vertex_flag = 0;
00069   normal_flag = 0;
00070   color_flag = 0;
00071   texcoord_flag = 0;
00072 
00073   em_vertex.uprime = -1.0;
00074   em_normal.uprime = -1.0;
00075   em_color.uprime = -1.0;
00076   em_texcoord.uprime = -1.0;
00077 }
00078 
00079 OpenGLCurveEvaluator::~OpenGLCurveEvaluator(void) 
00080 { 
00081 }
00082 
00083 /* added nonsense to avoid the warning messages at compile time */
00084 void
00085 OpenGLCurveEvaluator::addMap(CurveMap *m)
00086 {
00087     m = m;
00088 }
00089 
00090 void
00091 OpenGLCurveEvaluator::range1f(long type, REAL *from, REAL *to)
00092 {
00093     type = type;
00094     from = from;
00095     to = to;
00096 }
00097 
00098 void
00099 OpenGLCurveEvaluator::domain1f(REAL ulo, REAL uhi)
00100 {
00101     ulo = ulo;
00102     uhi = uhi;
00103 }
00104 
00105 void
00106 OpenGLCurveEvaluator::bgnline(void)
00107 {
00108   if(output_triangles)
00109     beginCallBack(GL_LINE_STRIP, userData);
00110   else
00111     glBegin((GLenum) GL_LINE_STRIP);
00112 }
00113 
00114 void
00115 OpenGLCurveEvaluator::endline(void)
00116 {
00117   if(output_triangles)
00118     endCallBack(userData);
00119   else
00120     glEnd();
00121 }
00122 
00123 /*---------------------------------------------------------------------------
00124  * disable - turn off a curve map
00125  *---------------------------------------------------------------------------
00126  */
00127 void
00128 OpenGLCurveEvaluator::disable(long type)
00129 {
00130     glDisable((GLenum) type);
00131 }
00132 
00133 /*---------------------------------------------------------------------------
00134  * enable - turn on a curve map
00135  *---------------------------------------------------------------------------
00136  */
00137 void
00138 OpenGLCurveEvaluator::enable(long type)
00139 {
00140     glEnable((GLenum) type);
00141 }
00142 
00143 /*-------------------------------------------------------------------------
00144  * mapgrid1f - define a lattice of points with origin and offset
00145  *-------------------------------------------------------------------------
00146  */
00147 void 
00148 OpenGLCurveEvaluator::mapgrid1f(long nu, REAL u0, REAL u1)
00149 {
00150   if(output_triangles)
00151     {
00152       global_grid_u0 = u0;
00153       global_grid_u1 = u1;
00154       global_grid_nu = (int) nu;
00155     }
00156   else
00157     glMapGrid1f((GLint) nu, (GLfloat) u0, (GLfloat) u1);
00158 }
00159 
00160 /*-------------------------------------------------------------------------
00161  * bgnmap1 - preamble to curve definition and evaluations
00162  *-------------------------------------------------------------------------
00163  */
00164 void
00165 OpenGLCurveEvaluator::bgnmap1f(long)
00166 {
00167   if(output_triangles)
00168     {
00169       //initialized so that no maps are set initially
00170       vertex_flag = 0;
00171       normal_flag = 0;
00172       color_flag = 0;
00173       texcoord_flag = 0;
00174       //no need to worry about gl states when doing callback
00175     }
00176   else
00177     glPushAttrib((GLbitfield) GL_EVAL_BIT);
00178 }
00179 
00180 /*-------------------------------------------------------------------------
00181  * endmap1 - postamble to a curve map
00182  *-------------------------------------------------------------------------
00183  */
00184 void
00185 OpenGLCurveEvaluator::endmap1f(void)
00186 {
00187   if(output_triangles)
00188     {
00189       
00190     }
00191   else
00192     glPopAttrib();
00193 }
00194 
00195 /*-------------------------------------------------------------------------
00196  * map1f - pass a desription of a curve map
00197  *-------------------------------------------------------------------------
00198  */
00199 void
00200 OpenGLCurveEvaluator::map1f(
00201     long type,          /* map type */
00202     REAL ulo,           /* lower parametric bound */
00203     REAL uhi,           /* upper parametric bound */
00204     long stride,        /* distance to next point in REALS */
00205     long order,         /* parametric order */
00206     REAL *pts           /* control points */
00207 )
00208 {
00209   if(output_triangles)
00210     {
00211       int dimension;
00212       int which;
00213       switch(type){
00214       case GL_MAP1_VERTEX_3:
00215     which = 0;
00216     dimension = 3;
00217     break;
00218       case GL_MAP1_VERTEX_4:
00219     which=0;
00220     dimension = 4;
00221     break;
00222       case GL_MAP1_INDEX:
00223     which=2;
00224     dimension = 1;
00225     break;
00226       case GL_MAP1_COLOR_4:
00227     which=2;
00228     dimension = 4;
00229     break;
00230       case GL_MAP1_NORMAL:
00231     which=1;
00232     dimension = 3;
00233     break;
00234       case GL_MAP1_TEXTURE_COORD_1:
00235     which=3;
00236     dimension = 1;
00237     break;
00238       case GL_MAP1_TEXTURE_COORD_2:
00239     which=3;
00240     dimension = 2;
00241     break;
00242     
00243       case GL_MAP1_TEXTURE_COORD_3:
00244     which=3;
00245     dimension = 3;
00246     break;
00247       case GL_MAP1_TEXTURE_COORD_4:
00248     which=3;
00249     dimension = 4;
00250     break;  
00251       /* make GCC happy */
00252       default:
00253     which=0;
00254     dimension = 0;
00255     break;  
00256       }
00257       inMap1f(which, dimension, ulo, uhi, stride, order, pts);        
00258     }       
00259   else
00260     glMap1f((GLenum) type, (GLfloat) ulo, (GLfloat) uhi, (GLint) stride, 
00261         (GLint) order, (const GLfloat *) pts);
00262 }
00263 
00264 /*-------------------------------------------------------------------------
00265  * mapmesh1f - evaluate a mesh of points on lattice
00266  *-------------------------------------------------------------------------
00267  */
00268 void OpenGLCurveEvaluator::mapmesh1f(long style, long from, long to)
00269 {
00270   if(output_triangles)
00271     {
00272       inMapMesh1f((int) from, (int) to);      
00273     }
00274   else
00275     {
00276       switch(style) {
00277       default:
00278       case N_MESHFILL:
00279       case N_MESHLINE:
00280     glEvalMesh1((GLenum) GL_LINE, (GLint) from, (GLint) to);
00281     break;
00282       case N_MESHPOINT:
00283     glEvalMesh1((GLenum) GL_POINT, (GLint) from, (GLint) to);
00284     break;
00285       }
00286     }
00287 }
00288 
00289 /*-------------------------------------------------------------------------
00290  * evalpoint1i - evaluate a point on a curve
00291  *-------------------------------------------------------------------------
00292  */
00293 void OpenGLCurveEvaluator::evalpoint1i(long i)
00294 {
00295     glEvalPoint1((GLint) i);
00296 }
00297 
00298 /*-------------------------------------------------------------------------
00299  * evalcoord1f - evaluate a point on a curve
00300  *-------------------------------------------------------------------------
00301  */
00302 void OpenGLCurveEvaluator::evalcoord1f(long, REAL u)
00303 {
00304     glEvalCoord1f((GLfloat) u);
00305 }
00306 
00307 void
00308 #ifdef _WIN32
00309 OpenGLCurveEvaluator::putCallBack(GLenum which, void (GLAPIENTRY *fn)())
00310 #else
00311 OpenGLCurveEvaluator::putCallBack(GLenum which, _GLUfuncptr fn)
00312 #endif
00313 {
00314   switch(which)
00315   {
00316     case GLU_NURBS_BEGIN:
00317       beginCallBackN = (void (GLAPIENTRY *) (GLenum)) fn;
00318       break;
00319     case GLU_NURBS_END:
00320       endCallBackN = (void (GLAPIENTRY *) (void)) fn;
00321       break;
00322     case GLU_NURBS_VERTEX:
00323       vertexCallBackN = (void (GLAPIENTRY *) (const GLfloat*)) fn;
00324       break;
00325     case GLU_NURBS_NORMAL:
00326       normalCallBackN = (void (GLAPIENTRY *) (const GLfloat*)) fn;
00327       break;
00328     case GLU_NURBS_COLOR:
00329       colorCallBackN = (void (GLAPIENTRY *) (const GLfloat*)) fn;
00330       break;
00331     case GLU_NURBS_TEXTURE_COORD:
00332       texcoordCallBackN = (void (GLAPIENTRY *) (const GLfloat*)) fn;
00333       break;
00334     case GLU_NURBS_BEGIN_DATA:
00335       beginCallBackData = (void (GLAPIENTRY *) (GLenum, void*)) fn;
00336       break;
00337     case GLU_NURBS_END_DATA:
00338       endCallBackData = (void (GLAPIENTRY *) (void*)) fn;
00339       break;
00340     case GLU_NURBS_VERTEX_DATA:
00341       vertexCallBackData = (void (GLAPIENTRY *) (const GLfloat*, void*)) fn;
00342       break;
00343     case GLU_NURBS_NORMAL_DATA:
00344       normalCallBackData = (void (GLAPIENTRY *) (const GLfloat*, void*)) fn;
00345       break;
00346     case GLU_NURBS_COLOR_DATA:
00347       colorCallBackData = (void (GLAPIENTRY *) (const GLfloat*, void*)) fn;
00348       break;
00349     case GLU_NURBS_TEXTURE_COORD_DATA:
00350       texcoordCallBackData = (void (GLAPIENTRY *) (const GLfloat*, void*)) fn;
00351       break;
00352   }
00353 }
00354 
00355 void
00356 OpenGLCurveEvaluator::beginCallBack(GLenum which, void *data)
00357 {
00358   if(beginCallBackData)
00359     beginCallBackData(which, data);
00360   else if(beginCallBackN)
00361     beginCallBackN(which);
00362 }
00363 
00364 void
00365 OpenGLCurveEvaluator::endCallBack(void *data)
00366 {
00367   if(endCallBackData)
00368     endCallBackData(data);
00369   else if(endCallBackN)
00370     endCallBackN();
00371 }
00372 
00373 void
00374 OpenGLCurveEvaluator::vertexCallBack(const GLfloat *vert, void* data)
00375 {
00376   if(vertexCallBackData)
00377     vertexCallBackData(vert, data);
00378   else if(vertexCallBackN)
00379     vertexCallBackN(vert);
00380 }
00381 
00382 
00383 void
00384 OpenGLCurveEvaluator::normalCallBack(const GLfloat *normal, void* data)
00385 {
00386   if(normalCallBackData)
00387     normalCallBackData(normal, data);
00388   else if(normalCallBackN)
00389     normalCallBackN(normal);
00390 }
00391 
00392 void
00393 OpenGLCurveEvaluator::colorCallBack(const GLfloat *color, void* data)
00394 {
00395   if(colorCallBackData)
00396     colorCallBackData(color, data);
00397   else if(colorCallBackN)
00398     colorCallBackN(color);
00399 }
00400 
00401 void
00402 OpenGLCurveEvaluator::texcoordCallBack(const GLfloat *texcoord, void* data)
00403 {
00404   if(texcoordCallBackData)
00405     texcoordCallBackData(texcoord, data);
00406   else if(texcoordCallBackN)
00407     texcoordCallBackN(texcoord);
00408 }

Generated on Sun May 27 2012 04:23:37 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.