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

glsurfeval.h
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  * glsurfeval.h
00037  *
00038  */
00039 
00040 #ifndef __gluglsurfeval_h_
00041 #define __gluglsurfeval_h_
00042 
00043 #include "basicsurfeval.h"
00044 #include "bezierPatchMesh.h" //in case output triangles
00045 #include <GL/gl.h>
00046 #include <GL/glu.h>
00047 
00048 class SurfaceMap;
00049 class OpenGLSurfaceEvaluator;
00050 class StoredVertex;
00051 
00052 #define TYPECOORD   1
00053 #define TYPEPOINT   2
00054 
00055 /* Cache up to 3 vertices from tmeshes */
00056 #define VERTEX_CACHE_SIZE   3
00057 
00058 /*for internal evaluator callback stuff*/
00059 #ifndef IN_MAX_BEZIER_ORDER
00060 #define IN_MAX_BEZIER_ORDER 40 /*XXX should be bigger than machine order*/
00061 #endif
00062 
00063 #ifndef IN_MAX_DIMENSION
00064 #define IN_MAX_DIMENSION 4
00065 #endif
00066 
00067 typedef struct surfEvalMachine{
00068   REAL uprime;//cached previusly evaluated uprime.
00069   REAL vprime;
00070   int k; /*the dimension*/
00071   REAL u1;
00072   REAL u2;
00073   int ustride;
00074   int uorder;
00075   REAL v1;
00076   REAL v2;
00077   int vstride;
00078   int vorder;
00079   REAL ctlPoints[IN_MAX_BEZIER_ORDER*IN_MAX_BEZIER_ORDER*IN_MAX_DIMENSION];
00080   REAL ucoeff[IN_MAX_BEZIER_ORDER]; /*cache the polynomial values*/
00081   REAL vcoeff[IN_MAX_BEZIER_ORDER];
00082   REAL ucoeffDeriv[IN_MAX_BEZIER_ORDER]; /*cache the polynomial derivatives*/
00083   REAL vcoeffDeriv[IN_MAX_BEZIER_ORDER];
00084 } surfEvalMachine;
00085 
00086 
00087 
00088 class StoredVertex {
00089 public:
00090             StoredVertex() { type = 0; }
00091         ~StoredVertex(void) {}
00092     void    saveEvalCoord(REAL x, REAL y)
00093             {coord[0] = x; coord[1] = y; type = TYPECOORD; }
00094     void    saveEvalPoint(long x, long y)
00095             {point[0] = x; point[1] = y; type = TYPEPOINT; }
00096     void    invoke(OpenGLSurfaceEvaluator *eval);
00097 
00098 private:
00099     int     type;
00100     REAL    coord[2];
00101     long    point[2];
00102 };
00103 
00104 class OpenGLSurfaceEvaluator : public BasicSurfaceEvaluator {
00105 public:
00106             OpenGLSurfaceEvaluator();
00107                 virtual ~OpenGLSurfaceEvaluator( void );
00108     void        polymode( long style );
00109     void        range2f( long, REAL *, REAL * );
00110     void        domain2f( REAL, REAL, REAL, REAL );
00111     void        addMap( SurfaceMap * ) { }
00112 
00113     void        enable( long );
00114     void        disable( long );
00115     void        bgnmap2f( long );
00116     void        map2f( long, REAL, REAL, long, long,
00117                      REAL, REAL, long, long, REAL * );
00118     void        mapgrid2f( long, REAL, REAL, long, REAL, REAL );
00119     void        mapmesh2f( long, long, long, long, long );
00120     void        evalcoord2f( long, REAL, REAL );
00121     void        evalpoint2i( long, long );
00122     void        endmap2f( void );
00123 
00124     void        bgnline( void );
00125     void        endline( void );
00126     void        bgnclosedline( void );
00127     void        endclosedline( void );
00128     void        bgntmesh( void );
00129     void        swaptmesh( void );
00130     void        endtmesh( void );
00131     void        bgnqstrip( void );
00132     void        endqstrip( void );
00133 
00134     void                bgntfan( void );
00135     void                endtfan( void );
00136     void                evalUStrip(int n_upper, REAL v_upper, REAL* upper_val,
00137                                    int n_lower, REAL v_lower, REAL* lower_val);
00138     void                evalVStrip(int n_left, REAL u_left, REAL* left_val,
00139                                    int n_right, REAL u_right, REAL* right_val);
00140 
00141     void        coord2f( REAL, REAL );
00142     void        point2i( long, long );
00143 
00144     void        newtmeshvert( REAL, REAL );
00145     void        newtmeshvert( long, long );
00146 
00147 #ifdef _WIN32
00148     void            putCallBack(GLenum which, void (APIENTRY *fn)() );
00149 #else
00150     void            putCallBack(GLenum which, _GLUfuncptr fn );
00151 #endif
00152 
00153     int                 get_vertices_call_back()
00154       {
00155     return output_triangles;
00156       }
00157     void                put_vertices_call_back(int flag)
00158       {
00159     output_triangles = flag;
00160       }
00161 
00162     void                 put_callback_auto_normal(int flag)
00163       {
00164         callback_auto_normal = flag;
00165       }
00166 
00167    int                   get_callback_auto_normal()
00168      {
00169         return callback_auto_normal;
00170       }
00171 
00172    void                  set_callback_userData(void* data)
00173      {
00174        userData = data;
00175      }
00176 
00177     /**************begin for LOD_eval_list***********/
00178     void LOD_eval_list(int level);
00179 
00180 
00181 
00182 
00183 private:
00184     StoredVertex    *vertexCache[VERTEX_CACHE_SIZE];
00185     int         tmeshing;
00186     int         which;
00187     int         vcount;
00188 
00189     GLint              gl_polygon_mode[2];/*to save and restore so that
00190                      *no side effect
00191                      */
00192     bezierPatchMesh        *global_bpm; //for output triangles
00193     int                output_triangles; //true 1 or false 0
00194 
00195 
00196 
00197     void (GLAPIENTRY *beginCallBackN) (GLenum type);
00198     void (GLAPIENTRY *endCallBackN)   (void);
00199     void (GLAPIENTRY *vertexCallBackN) (const GLfloat *vert);
00200     void (GLAPIENTRY *normalCallBackN) (const GLfloat *normal);
00201     void (GLAPIENTRY *colorCallBackN) (const GLfloat *color);
00202     void (GLAPIENTRY *texcoordCallBackN) (const GLfloat *texcoord);
00203 
00204     void (GLAPIENTRY *beginCallBackData) (GLenum type, void* data);
00205     void (GLAPIENTRY *endCallBackData)   (void* data);
00206     void (GLAPIENTRY *vertexCallBackData) (const GLfloat *vert, void* data);
00207     void (GLAPIENTRY *normalCallBackData) (const GLfloat *normal, void* data);
00208     void (GLAPIENTRY *colorCallBackData) (const GLfloat *color, void* data);
00209     void (GLAPIENTRY *texcoordCallBackData) (const GLfloat *texcoord, void* data);
00210 
00211     void               beginCallBack (GLenum type, void* data);
00212     void               endCallBack   (void* data);
00213     void               vertexCallBack (const GLfloat *vert, void* data);
00214     void               normalCallBack (const GLfloat *normal, void* data);
00215     void               colorCallBack (const GLfloat *color, void* data);
00216     void               texcoordCallBack (const GLfloat *texcoord, void* data);
00217 
00218 
00219     void* userData; //the opaque pointer for Data callback functions.
00220 
00221    /*LOD evaluation*/
00222    void LOD_triangle(REAL A[2], REAL B[2], REAL C[2],
00223              int level);
00224    void LOD_eval(int num_vert, REAL* verts, int type, int level);
00225 
00226   int LOD_eval_level; //set by LOD_eval_list()
00227 
00228    /*************begin for internal evaluators*****************/
00229 
00230  /*the following global variables are only defined in this file.
00231  *They are used to cache the precomputed Bezier polynomial values.
00232  *These calues may be used consecutively in which case we don't have
00233  *recompute these values again.
00234  */
00235  int global_uorder; /*store the uorder in the previous evaluation*/
00236  int global_vorder; /*store the vorder in the previous evaluation*/
00237  REAL global_uprime;
00238  REAL global_vprime;
00239  REAL global_vprime_BV;
00240  REAL global_uprime_BU;
00241  int global_uorder_BV; /*store the uorder in the previous evaluation*/
00242  int global_vorder_BV; /*store the vorder in the previous evaluation*/
00243  int global_uorder_BU; /*store the uorder in the previous evaluation*/
00244  int global_vorder_BU; /*store the vorder in the previous evaluation*/
00245 
00246  REAL global_ucoeff[IN_MAX_BEZIER_ORDER]; /*cache the polynomial values*/
00247  REAL global_vcoeff[IN_MAX_BEZIER_ORDER];
00248  REAL global_ucoeffDeriv[IN_MAX_BEZIER_ORDER]; /*cache the polynomial derivatives*/
00249  REAL global_vcoeffDeriv[IN_MAX_BEZIER_ORDER];
00250 
00251  REAL global_BV[IN_MAX_BEZIER_ORDER][IN_MAX_DIMENSION];
00252  REAL global_PBV[IN_MAX_BEZIER_ORDER][IN_MAX_DIMENSION];
00253  REAL global_BU[IN_MAX_BEZIER_ORDER][IN_MAX_DIMENSION];
00254  REAL global_PBU[IN_MAX_BEZIER_ORDER][IN_MAX_DIMENSION];
00255  REAL* global_baseData;
00256 
00257  int    global_ev_k; /*the dimension*/
00258  REAL global_ev_u1;
00259  REAL global_ev_u2;
00260  int    global_ev_ustride;
00261  int    global_ev_uorder;
00262  REAL global_ev_v1;
00263  REAL global_ev_v2;
00264  int    global_ev_vstride;
00265  int    global_ev_vorder;
00266  REAL global_ev_ctlPoints[IN_MAX_BEZIER_ORDER*IN_MAX_BEZIER_ORDER*IN_MAX_DIMENSION];
00267 
00268  REAL  global_grid_u0;
00269  REAL  global_grid_u1;
00270  int     global_grid_nu;
00271  REAL  global_grid_v0;
00272  REAL  global_grid_v1;
00273  int     global_grid_nv;
00274 
00275 /*functions*/
00276  void inDoDomain2WithDerivs(int k, REAL u, REAL v,
00277                 REAL u1, REAL u2, int uorder,
00278                 REAL v1,  REAL v2, int vorder,
00279                 REAL *baseData,
00280                 REAL *retPoint, REAL *retdu, REAL *retdv);
00281  void inPreEvaluate(int order, REAL vprime, REAL *coeff);
00282  void inPreEvaluateWithDeriv(int order, REAL vprime, REAL *coeff, REAL *coeffDeriv);
00283  void inComputeFirstPartials(REAL *p, REAL *pu, REAL *pv);
00284  void inComputeNormal2(REAL *pu, REAL *pv, REAL *n);
00285  void inDoEvalCoord2(REAL u, REAL v,
00286              REAL *retPoint, REAL *retNormal);
00287  void inDoEvalCoord2NOGE(REAL u, REAL v,
00288              REAL *retPoint, REAL *retNormal);
00289  void inMap2f(int k,
00290           REAL ulower,
00291           REAL uupper,
00292           int ustride,
00293           int uorder,
00294           REAL vlower,
00295           REAL vupper,
00296           int vstride,
00297           int vorder,
00298           REAL *ctlPoints);
00299 
00300  void inMapGrid2f(int nu, REAL u0, REAL u1,
00301           int nv, REAL v0, REAL v1);
00302 
00303  void inEvalMesh2(int lowU, int lowV, int highU, int highV);
00304  void inEvalPoint2(int i, int j);
00305  void inEvalCoord2f(REAL u, REAL v);
00306 
00307 void inEvalULine(int n_points, REAL v, REAL* u_vals,
00308     int stride, REAL ret_points[][3], REAL ret_normals[][3]);
00309 
00310 void inEvalVLine(int n_points, REAL u, REAL* v_vals,
00311     int stride, REAL ret_points[][3], REAL ret_normals[][3]);
00312 
00313 void inEvalUStrip(int n_upper, REAL v_upper, REAL* upper_val,
00314                        int n_lower, REAL v_lower, REAL* lower_val
00315                        );
00316 void inEvalVStrip(int n_left, REAL u_left, REAL* left_val, int n_right, REAL u_right, REAL* right_val);
00317 
00318 void inPreEvaluateBV(int k, int uorder, int vorder, REAL vprime, REAL *baseData);
00319 void inPreEvaluateBU(int k, int uorder, int vorder, REAL uprime, REAL *baseData);
00320 void inPreEvaluateBV_intfac(REAL v )
00321   {
00322    inPreEvaluateBV(global_ev_k, global_ev_uorder, global_ev_vorder, (v-global_ev_v1)/(global_ev_v2-global_ev_v1), global_ev_ctlPoints);
00323   }
00324 
00325 void inPreEvaluateBU_intfac(REAL u)
00326   {
00327     inPreEvaluateBU(global_ev_k, global_ev_uorder, global_ev_vorder, (u-global_ev_u1)/(global_ev_u2-global_ev_u1), global_ev_ctlPoints);
00328   }
00329 
00330 void inDoDomain2WithDerivsBV(int k, REAL u, REAL v,
00331                  REAL u1, REAL u2, int uorder,
00332                  REAL v1, REAL v2, int vorder,
00333                  REAL *baseData,
00334                  REAL *retPoint, REAL* retdu, REAL *retdv);
00335 
00336 void inDoDomain2WithDerivsBU(int k, REAL u, REAL v,
00337                  REAL u1, REAL u2, int uorder,
00338                  REAL v1, REAL v2, int vorder,
00339                  REAL *baseData,
00340                  REAL *retPoint, REAL* retdu, REAL *retdv);
00341 
00342 
00343 void inDoEvalCoord2NOGE_BV(REAL u, REAL v,
00344                REAL *retPoint, REAL *retNormal);
00345 
00346 void inDoEvalCoord2NOGE_BU(REAL u, REAL v,
00347                REAL *retPoint, REAL *retNormal);
00348 
00349 void inBPMEval(bezierPatchMesh* bpm);
00350 void inBPMListEval(bezierPatchMesh* list);
00351 
00352 /*-------------begin for surfEvalMachine -------------*/
00353 surfEvalMachine em_vertex;
00354 surfEvalMachine em_normal;
00355 surfEvalMachine em_color;
00356 surfEvalMachine em_texcoord;
00357 
00358 int auto_normal_flag; //whether to output normla or not in callback
00359                       //determined by GL_AUTO_NORMAL and callback_auto_normal
00360 int callback_auto_normal; //GLU_CALLBACK_AUTO_NORMAL_EXT
00361 int vertex_flag;
00362 int normal_flag;
00363 int color_flag;
00364 int texcoord_flag;
00365 
00366 void inMap2fEM(int which, //0:vert,1:norm,2:color,3:tex
00367            int dimension,
00368           REAL ulower,
00369           REAL uupper,
00370           int ustride,
00371           int uorder,
00372           REAL vlower,
00373           REAL vupper,
00374           int vstride,
00375           int vorder,
00376           REAL *ctlPoints);
00377 
00378 void inDoDomain2WithDerivsEM(surfEvalMachine *em, REAL u, REAL v,
00379                 REAL *retPoint, REAL *retdu, REAL *retdv);
00380 void inDoDomain2EM(surfEvalMachine *em, REAL u, REAL v,
00381                 REAL *retPoint);
00382  void inDoEvalCoord2EM(REAL u, REAL v);
00383 
00384 void inBPMEvalEM(bezierPatchMesh* bpm);
00385 void inBPMListEvalEM(bezierPatchMesh* list);
00386 
00387 /*-------------end for surfEvalMachine -------------*/
00388 
00389 
00390    /*************end for internal evaluators*****************/
00391 
00392 };
00393 
00394 inline void StoredVertex::invoke(OpenGLSurfaceEvaluator *eval)
00395 {
00396     switch(type) {
00397       case TYPECOORD:
00398     eval->coord2f(coord[0], coord[1]);
00399     break;
00400       case TYPEPOINT:
00401     eval->point2i(point[0], point[1]);
00402     break;
00403       default:
00404     break;
00405     }
00406 }
00407 
00408 #endif /* __gluglsurfeval_h_ */

Generated on Sun May 27 2012 04:23:38 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.