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

backend.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  * backend.c++
00037  *
00038  * $Date: 2009-08-30 15:53:16 +0000 (Sun, 30 Aug 2009) $ $Revision: 1.1 $
00039  * $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/lib/glu32/libnurbs/internals/backend.cc,v 1.1 2004/02/02 16:39:10 navaraf Exp $
00040  */
00041 
00042 /* Bezier surface backend
00043     - interprets display mode (wireframe,shaded,...)
00044 */
00045 #include <stdio.h>
00046 #include "glimports.h"
00047 #include "mystdio.h"
00048 #include "backend.h"
00049 #include "basiccrveval.h"
00050 #include "basicsurfeval.h"
00051 #include "nurbsconsts.h"
00052 
00053 #define NOWIREFRAME
00054 
00055 
00056 /*-------------------------------------------------------------------------
00057  * bgnsurf - preamble to surface definition and evaluations
00058  *-------------------------------------------------------------------------
00059  */
00060 void
00061 Backend::bgnsurf( int wiretris, int wirequads, long nuid )
00062 {
00063 /*#ifndef NOWIREFRAME*/ //need this for old version
00064     wireframetris = wiretris;
00065     wireframequads = wirequads;
00066 /*#endif*/
00067 
00068     /*in the spec, GLU_DISPLAY_MODE is either
00069      * GLU_FILL
00070      * GLU_OUTLINE_POLY
00071      * GLU_OUTLINE_PATCH.
00072      *In fact, GLU_FLL is has the same effect as
00073      * set GL_FRONT_AND_BACK to be GL_FILL
00074      * and GLU_OUTLINE_POLY is the same as set 
00075      *     GL_FRONT_AND_BACK to be GL_LINE
00076      *It is more efficient to do this once at the beginning of
00077      *each surface than to do it for each primitive.
00078      *   The internal has more options: outline_triangle and outline_quad
00079      *can be seperated. But since this is not in spec, and more importantly,
00080      *this is not so useful, so we don't need to keep this option.
00081      */
00082 
00083     surfaceEvaluator.bgnmap2f( nuid );
00084 
00085     if(wiretris)
00086       surfaceEvaluator.polymode(N_MESHLINE);
00087     else
00088       surfaceEvaluator.polymode(N_MESHFILL);
00089 }
00090 
00091 void
00092 Backend::patch( REAL ulo, REAL uhi, REAL vlo, REAL vhi )
00093 {
00094     surfaceEvaluator.domain2f( ulo, uhi, vlo, vhi );
00095 }
00096 
00097 void
00098 Backend::surfbbox( long type, REAL *from, REAL *to )
00099 {
00100     surfaceEvaluator.range2f( type, from, to );
00101 }
00102 
00103 /*-------------------------------------------------------------------------
00104  * surfpts - pass a desription of a surface map
00105  *-------------------------------------------------------------------------
00106  */
00107 void 
00108 Backend::surfpts(
00109     long type,      /* geometry, color, texture, normal */
00110     REAL *pts,      /* control points           */
00111     long ustride,   /* distance to next point in u direction */
00112     long vstride,   /* distance to next point in v direction */
00113     int uorder, /* u parametric order           */
00114     int vorder, /* v parametric order           */
00115     REAL ulo,       /* u lower bound            */
00116     REAL uhi,       /* u upper bound            */
00117     REAL vlo,       /* v lower bound            */
00118     REAL vhi )      /* v upper bound            */
00119 {
00120     surfaceEvaluator.map2f( type,ulo,uhi,ustride,uorder,vlo,vhi,vstride,vorder,pts );
00121     surfaceEvaluator.enable( type );
00122 }
00123 
00124 /*-------------------------------------------------------------------------
00125  * surfgrid - define a lattice of points with origin and offset
00126  *-------------------------------------------------------------------------
00127  */
00128 void
00129 Backend::surfgrid( REAL u0, REAL u1, long nu, REAL v0, REAL v1, long nv )
00130 {
00131     surfaceEvaluator.mapgrid2f( nu, u0, u1, nv, v0, v1 );
00132 }
00133 
00134 /*-------------------------------------------------------------------------
00135  * surfmesh - evaluate a mesh of points on lattice
00136  *-------------------------------------------------------------------------
00137  */
00138 void
00139 Backend::surfmesh( long u, long v, long n, long m )
00140 {
00141 #ifndef NOWIREFRAME
00142     if( wireframequads ) {
00143     long v0,  v1;
00144     long u0f = u, u1f = u+n;
00145     long v0f = v, v1f = v+m;
00146     long parity = (u & 1);
00147 
00148         for( v0 = v0f, v1 = v0f++ ; v0<v1f; v0 = v1, v1++ ) {
00149         surfaceEvaluator.bgnline();
00150         for( long u = u0f; u<=u1f; u++ ) {
00151         if( parity ) {
00152             surfaceEvaluator.evalpoint2i( u, v0 );
00153             surfaceEvaluator.evalpoint2i( u, v1 );
00154         } else {
00155             surfaceEvaluator.evalpoint2i( u, v1 );
00156             surfaceEvaluator.evalpoint2i( u, v0 );
00157         }
00158         parity = 1 - parity;
00159         }
00160         surfaceEvaluator.endline();
00161     }
00162     } else {
00163     surfaceEvaluator.mapmesh2f( N_MESHFILL, u, u+n, v, v+m );
00164     }
00165 #else
00166     if( wireframequads ) {
00167 
00168     surfaceEvaluator.mapmesh2f( N_MESHLINE, u, u+n, v, v+m );
00169     } else {
00170 
00171     surfaceEvaluator.mapmesh2f( N_MESHFILL, u, u+n, v, v+m );
00172     }
00173 #endif
00174 }
00175 
00176 /*-------------------------------------------------------------------------
00177  * endsurf - postamble to surface
00178  *-------------------------------------------------------------------------
00179  */
00180 void
00181 Backend::endsurf( void )
00182 {
00183     surfaceEvaluator.endmap2f();
00184 }
00185 
00186 /***************************************/
00187 void
00188 Backend::bgntfan( void )
00189 {
00190   surfaceEvaluator.bgntfan();
00191 /*
00192   if(wireframetris) 
00193     surfaceEvaluator.polymode( N_MESHLINE );
00194   else
00195     surfaceEvaluator.polymode( N_MESHFILL );
00196 */
00197 }
00198 
00199 void
00200 Backend::endtfan( void )
00201 {
00202    surfaceEvaluator.endtfan();
00203 }
00204 
00205 void
00206 Backend::bgnqstrip( void )
00207 {
00208    surfaceEvaluator.bgnqstrip();
00209 /*
00210   if(wireframequads)
00211     surfaceEvaluator.polymode( N_MESHLINE );
00212   else
00213     surfaceEvaluator.polymode( N_MESHFILL );    
00214 */
00215 }
00216 
00217 void
00218 Backend::endqstrip( void )
00219 {
00220    surfaceEvaluator.endqstrip();
00221 }
00222 
00223 void
00224 Backend::evalUStrip(int n_upper, REAL v_upper, REAL* upper_val,
00225                        int n_lower, REAL v_lower, REAL* lower_val
00226                        )
00227 {
00228     surfaceEvaluator.evalUStrip(n_upper, v_upper, upper_val, 
00229                       n_lower, v_lower, lower_val);
00230 }
00231 
00232 void 
00233 Backend::evalVStrip(int n_left, REAL u_left, REAL* left_val, 
00234             int n_right, REAL u_right, REAL* right_val
00235             )
00236 {
00237   surfaceEvaluator.evalVStrip(n_left, u_left, left_val,
00238                 n_right, u_right, right_val);
00239 }
00240 
00241 /***************************************/
00242    
00243 
00244 /*-------------------------------------------------------------------------
00245  * bgntmesh - preamble to a triangle mesh
00246  *-------------------------------------------------------------------------
00247  */
00248 void
00249 Backend::bgntmesh( const char * )       
00250 {
00251 #ifndef NOWIREFRAME
00252 
00253     meshindex = 0;  /* I think these need to be initialized to zero */
00254     npts = 0;
00255 
00256     if( !wireframetris ) {
00257         surfaceEvaluator.bgntmesh();
00258     }
00259 #else
00260 
00261     if( wireframetris ) {
00262         surfaceEvaluator.bgntmesh();
00263     surfaceEvaluator.polymode( N_MESHLINE );
00264     } else {
00265         surfaceEvaluator.bgntmesh();
00266     surfaceEvaluator.polymode( N_MESHFILL );
00267     }
00268 #endif
00269 }
00270 
00271 void
00272 Backend::tmeshvert( GridTrimVertex *v )
00273 {
00274     if( v->isGridVert() ) {
00275     tmeshvert( v->g );
00276     } else {
00277     tmeshvert( v->t );
00278     }
00279 }
00280 
00281 void
00282 Backend::tmeshvertNOGE(TrimVertex *t)
00283 {
00284 //  surfaceEvaluator.inDoEvalCoord2NOGE( t->param[0], t->param[1], temp, ttt);
00285 #ifdef USE_OPTTT
00286     surfaceEvaluator.inDoEvalCoord2NOGE( t->param[0], t->param[1], t->cache_point, t->cache_normal);    
00287 #endif
00288 }
00289 
00290 //opt for a line with the same u.
00291 void
00292 Backend::tmeshvertNOGE_BU(TrimVertex *t)
00293 {
00294 #ifdef USE_OPTTT
00295     surfaceEvaluator.inDoEvalCoord2NOGE_BU( t->param[0], t->param[1], t->cache_point, t->cache_normal);    
00296 #endif
00297 }
00298 
00299 //opt for a line with the same v.
00300 void
00301 Backend::tmeshvertNOGE_BV(TrimVertex *t)
00302 {
00303 #ifdef USE_OPTTT
00304     surfaceEvaluator.inDoEvalCoord2NOGE_BV( t->param[0], t->param[1], t->cache_point, t->cache_normal);    
00305 #endif
00306 }
00307 
00308 void
00309 Backend::preEvaluateBU(REAL u)
00310 {
00311     surfaceEvaluator.inPreEvaluateBU_intfac(u);
00312 }
00313 
00314 void 
00315 Backend::preEvaluateBV(REAL v)
00316 {
00317     surfaceEvaluator.inPreEvaluateBV_intfac(v);
00318 }
00319 
00320 
00321 /*-------------------------------------------------------------------------
00322  * tmeshvert - evaluate a point on a triangle mesh
00323  *-------------------------------------------------------------------------
00324  */
00325 void
00326 Backend::tmeshvert( TrimVertex *t )
00327 {
00328     const REAL u = t->param[0];
00329     const REAL v = t->param[1];
00330 
00331 #ifndef NOWIREFRAME
00332     const long nuid = t->nuid;
00333 
00334     npts++;
00335     if( wireframetris ) {
00336     if( npts >= 3 ) {
00337         surfaceEvaluator.bgnclosedline();
00338         if( mesh[0][2] == 0 )
00339         surfaceEvaluator.evalcoord2f( mesh[0][3], mesh[0][0], mesh[0][1] );
00340         else
00341         surfaceEvaluator.evalpoint2i( (long) mesh[0][0], (long) mesh[0][1] );
00342         if( mesh[1][2] == 0 )
00343         surfaceEvaluator.evalcoord2f( mesh[1][3], mesh[1][0], mesh[1][1] );
00344         else
00345         surfaceEvaluator.evalpoint2i( (long) mesh[1][0], (long) mesh[1][1] );
00346         surfaceEvaluator.evalcoord2f( nuid, u, v );
00347         surfaceEvaluator.endclosedline();
00348     }
00349         mesh[meshindex][0] = u;
00350         mesh[meshindex][1] = v;
00351     mesh[meshindex][2] = 0;
00352     mesh[meshindex][3] = nuid;
00353         meshindex = (meshindex+1) % 2;
00354     } else {
00355     surfaceEvaluator.evalcoord2f( nuid, u, v );
00356     }
00357 #else
00358           
00359           surfaceEvaluator.evalcoord2f( 0, u, v );
00360 //for uninitial memory read          surfaceEvaluator.evalcoord2f( nuid, u, v );
00361 #endif
00362 }
00363 
00364 //the same as tmeshvert(trimvertex), for efficiency purpose
00365 void
00366 Backend::tmeshvert( REAL u, REAL v )
00367 {
00368 #ifndef NOWIREFRAME
00369     const long nuid = 0;
00370 
00371     npts++;
00372     if( wireframetris ) {
00373     if( npts >= 3 ) {
00374         surfaceEvaluator.bgnclosedline();
00375         if( mesh[0][2] == 0 )
00376         surfaceEvaluator.evalcoord2f( mesh[0][3], mesh[0][0], mesh[0][1] );
00377         else
00378         surfaceEvaluator.evalpoint2i( (long) mesh[0][0], (long) mesh[0][1] );
00379         if( mesh[1][2] == 0 )
00380         surfaceEvaluator.evalcoord2f( mesh[1][3], mesh[1][0], mesh[1][1] );
00381         else
00382         surfaceEvaluator.evalpoint2i( (long) mesh[1][0], (long) mesh[1][1] );
00383         surfaceEvaluator.evalcoord2f( nuid, u, v );
00384         surfaceEvaluator.endclosedline();
00385     }
00386         mesh[meshindex][0] = u;
00387         mesh[meshindex][1] = v;
00388     mesh[meshindex][2] = 0;
00389     mesh[meshindex][3] = nuid;
00390         meshindex = (meshindex+1) % 2;
00391     } else {
00392     surfaceEvaluator.evalcoord2f( nuid, u, v );
00393     }
00394 #else
00395           
00396           surfaceEvaluator.evalcoord2f( 0, u, v );
00397 #endif
00398 }
00399 
00400 /*-------------------------------------------------------------------------
00401  * tmeshvert - evaluate a grid point of a triangle mesh
00402  *-------------------------------------------------------------------------
00403  */
00404 void
00405 Backend::tmeshvert( GridVertex *g )
00406 {
00407     const long u = g->gparam[0];
00408     const long v = g->gparam[1];
00409 
00410 #ifndef NOWIREFRAME
00411     npts++;
00412     if( wireframetris ) {
00413     if( npts >= 3 ) {
00414         surfaceEvaluator.bgnclosedline();
00415         if( mesh[0][2] == 0 )
00416         surfaceEvaluator.evalcoord2f( (long) mesh[0][3], mesh[0][0], mesh[0][1] );
00417         else
00418         surfaceEvaluator.evalpoint2i( (long) mesh[0][0], (long) mesh[0][1] );
00419         if( mesh[1][2] == 0 )
00420         surfaceEvaluator.evalcoord2f( (long) mesh[1][3], mesh[1][0], mesh[1][1] );
00421         else
00422         surfaceEvaluator.evalpoint2i( (long) mesh[1][0], (long) mesh[1][1] );
00423         surfaceEvaluator.evalpoint2i( u, v );
00424         surfaceEvaluator.endclosedline();
00425     }
00426         mesh[meshindex][0] = u;
00427         mesh[meshindex][1] = v;
00428     mesh[meshindex][2] = 1;
00429         meshindex = (meshindex+1) % 2;
00430     } else {
00431         surfaceEvaluator.evalpoint2i( u, v );
00432     }
00433 #else
00434     surfaceEvaluator.evalpoint2i( u, v );
00435 #endif
00436 }
00437 
00438 /*-------------------------------------------------------------------------
00439  * swaptmesh - perform a swap of the triangle mesh pointers
00440  *-------------------------------------------------------------------------
00441  */
00442 void
00443 Backend::swaptmesh( void )
00444 {
00445 #ifndef NOWIREFRAME
00446     if( wireframetris ) {
00447         meshindex = 1 - meshindex;
00448     } else {
00449     surfaceEvaluator.swaptmesh();
00450     }
00451 #else
00452     surfaceEvaluator.swaptmesh();
00453 #endif
00454 }
00455 
00456 /*-------------------------------------------------------------------------
00457  * endtmesh - postamble to triangle mesh
00458  *-------------------------------------------------------------------------
00459  */
00460 void
00461 Backend::endtmesh( void )
00462 {
00463 #ifndef NOWIREFRAME
00464     if( ! wireframetris )
00465         surfaceEvaluator.endtmesh();
00466 #else
00467     surfaceEvaluator.endtmesh();
00468 /*    surfaceEvaluator.polymode( N_MESHFILL );*/
00469 #endif
00470 }
00471 
00472 
00473 /*-------------------------------------------------------------------------
00474  * bgnoutline - preamble to outlined rendering
00475  *-------------------------------------------------------------------------
00476  */
00477 void
00478 Backend::bgnoutline( void )
00479 {
00480     surfaceEvaluator.bgnline();
00481 }
00482 
00483 /*-------------------------------------------------------------------------
00484  * linevert - evaluate a point on an outlined contour
00485  *-------------------------------------------------------------------------
00486  */
00487 void
00488 Backend::linevert( TrimVertex *t )
00489 {
00490     surfaceEvaluator.evalcoord2f( t->nuid, t->param[0], t->param[1] );
00491 }
00492 
00493 /*-------------------------------------------------------------------------
00494  * linevert - evaluate a grid point of an outlined contour
00495  *-------------------------------------------------------------------------
00496  */
00497 void
00498 Backend::linevert( GridVertex *g )
00499 {
00500     surfaceEvaluator.evalpoint2i( g->gparam[0], g->gparam[1] );
00501 }
00502 
00503 /*-------------------------------------------------------------------------
00504  * endoutline - postamble to outlined rendering
00505  *-------------------------------------------------------------------------
00506  */
00507 void
00508 Backend::endoutline( void )
00509 {
00510     surfaceEvaluator.endline();
00511 }
00512 
00513 /*-------------------------------------------------------------------------
00514  * triangle - output a triangle 
00515  *-------------------------------------------------------------------------
00516  */
00517 void
00518 Backend::triangle( TrimVertex *a, TrimVertex *b, TrimVertex *c )
00519 {
00520 /*    bgntmesh( "spittriangle" );*/
00521     bgntfan();
00522     tmeshvert( a );
00523     tmeshvert( b );
00524     tmeshvert( c );
00525     endtfan();
00526 /*    endtmesh();*/
00527 }
00528 
00529 void 
00530 Backend::bgncurv( void )
00531 {
00532     curveEvaluator.bgnmap1f( 0 );
00533 }
00534 
00535 void
00536 Backend::segment( REAL ulo, REAL uhi )
00537 {
00538     curveEvaluator.domain1f( ulo, uhi );
00539 } 
00540 
00541 void 
00542 Backend::curvpts( 
00543     long type,          /* geometry, color, texture, normal */
00544     REAL *pts,          /* control points */
00545     long stride,        /* distance to next point */
00546     int order,          /* parametric order */
00547     REAL ulo,           /* lower parametric bound */
00548     REAL uhi )          /* upper parametric bound */
00549 
00550 {
00551     curveEvaluator.map1f( type, ulo, uhi, stride, order, pts );
00552     curveEvaluator.enable( type );
00553 }
00554 
00555 void 
00556 Backend::curvgrid( REAL u0, REAL u1, long nu )
00557 {
00558     curveEvaluator.mapgrid1f( nu, u0, u1 );
00559 }
00560 
00561 void 
00562 Backend::curvmesh( long from, long n )
00563 {
00564     curveEvaluator.mapmesh1f( N_MESHFILL, from, from+n );
00565 }
00566 
00567 void 
00568 Backend::curvpt(REAL u)
00569 {
00570     curveEvaluator.evalcoord1f( 0, u );
00571 }
00572 
00573 void 
00574 Backend::bgnline( void )        
00575 {
00576     curveEvaluator.bgnline();
00577 }
00578 
00579 void 
00580 Backend::endline( void )
00581 {
00582     curveEvaluator.endline();
00583 }
00584 
00585 void 
00586 Backend::endcurv( void )
00587 {
00588     curveEvaluator.endmap1f();
00589 }

Generated on Sat May 26 2012 04:22:15 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.