1f220fa62Smrg/* 2f220fa62Smrg** License Applicability. Except to the extent portions of this file are 3f220fa62Smrg** made subject to an alternative license as permitted in the SGI Free 4f220fa62Smrg** Software License B, Version 1.1 (the "License"), the contents of this 5f220fa62Smrg** file are subject only to the provisions of the License. You may not use 6f220fa62Smrg** this file except in compliance with the License. You may obtain a copy 7f220fa62Smrg** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 8f220fa62Smrg** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: 9f220fa62Smrg** 10f220fa62Smrg** http://oss.sgi.com/projects/FreeB 11f220fa62Smrg** 12f220fa62Smrg** Note that, as provided in the License, the Software is distributed on an 13f220fa62Smrg** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS 14f220fa62Smrg** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND 15f220fa62Smrg** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A 16f220fa62Smrg** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. 17f220fa62Smrg** 18f220fa62Smrg** Original Code. The Original Code is: OpenGL Sample Implementation, 19f220fa62Smrg** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, 20f220fa62Smrg** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. 21f220fa62Smrg** Copyright in any portions created by third parties is as indicated 22f220fa62Smrg** elsewhere herein. All Rights Reserved. 23f220fa62Smrg** 24f220fa62Smrg** Additional Notice Provisions: The application programming interfaces 25f220fa62Smrg** established by SGI in conjunction with the Original Code are The 26f220fa62Smrg** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released 27f220fa62Smrg** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version 28f220fa62Smrg** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X 29f220fa62Smrg** Window System(R) (Version 1.3), released October 19, 1998. This software 30f220fa62Smrg** was created using the OpenGL(R) version 1.2.1 Sample Implementation 31f220fa62Smrg** published by SGI, but has not been independently verified as being 32f220fa62Smrg** compliant with the OpenGL(R) version 1.2.1 Specification. 33f220fa62Smrg*/ 34f220fa62Smrg 35f220fa62Smrg/* 36f220fa62Smrg * backend.c++ 37f220fa62Smrg * 38f220fa62Smrg */ 39f220fa62Smrg 40f220fa62Smrg/* Bezier surface backend 41f220fa62Smrg - interprets display mode (wireframe,shaded,...) 42f220fa62Smrg*/ 43f220fa62Smrg#include <stdio.h> 44f220fa62Smrg#include "glimports.h" 45f220fa62Smrg#include "mystdio.h" 46f220fa62Smrg#include "backend.h" 47f220fa62Smrg#include "basiccrveval.h" 48f220fa62Smrg#include "basicsurfeval.h" 49f220fa62Smrg 50f220fa62Smrg#define NOWIREFRAME 51f220fa62Smrg 52f220fa62Smrg 53f220fa62Smrg/*------------------------------------------------------------------------- 54f220fa62Smrg * bgnsurf - preamble to surface definition and evaluations 55f220fa62Smrg *------------------------------------------------------------------------- 56f220fa62Smrg */ 57f220fa62Smrgvoid 58f220fa62SmrgBackend::bgnsurf( int wiretris, int wirequads, long nuid ) 59f220fa62Smrg{ 60f220fa62Smrg/*#ifndef NOWIREFRAME*/ //need this for old version 61f220fa62Smrg wireframetris = wiretris; 62f220fa62Smrg wireframequads = wirequads; 63f220fa62Smrg/*#endif*/ 64f220fa62Smrg 65f220fa62Smrg /*in the spec, GLU_DISPLAY_MODE is either 66f220fa62Smrg * GLU_FILL 67f220fa62Smrg * GLU_OUTLINE_POLY 68f220fa62Smrg * GLU_OUTLINE_PATCH. 69f220fa62Smrg *In fact, GLU_FLL is has the same effect as 70f220fa62Smrg * set GL_FRONT_AND_BACK to be GL_FILL 71f220fa62Smrg * and GLU_OUTLINE_POLY is the same as set 72f220fa62Smrg * GL_FRONT_AND_BACK to be GL_LINE 73f220fa62Smrg *It is more efficient to do this once at the beginning of 74f220fa62Smrg *each surface than to do it for each primitive. 75f220fa62Smrg * The internal has more options: outline_triangle and outline_quad 76f220fa62Smrg *can be seperated. But since this is not in spec, and more importantly, 77f220fa62Smrg *this is not so useful, so we don't need to keep this option. 78f220fa62Smrg */ 79f220fa62Smrg 80f220fa62Smrg surfaceEvaluator.bgnmap2f( nuid ); 81f220fa62Smrg 82f220fa62Smrg if(wiretris) 83f220fa62Smrg surfaceEvaluator.polymode(N_MESHLINE); 84f220fa62Smrg else 85f220fa62Smrg surfaceEvaluator.polymode(N_MESHFILL); 86f220fa62Smrg} 87f220fa62Smrg 88f220fa62Smrgvoid 89f220fa62SmrgBackend::patch( REAL ulo, REAL uhi, REAL vlo, REAL vhi ) 90f220fa62Smrg{ 91f220fa62Smrg surfaceEvaluator.domain2f( ulo, uhi, vlo, vhi ); 92f220fa62Smrg} 93f220fa62Smrg 94f220fa62Smrgvoid 95f220fa62SmrgBackend::surfbbox( long type, REAL *from, REAL *to ) 96f220fa62Smrg{ 97f220fa62Smrg surfaceEvaluator.range2f( type, from, to ); 98f220fa62Smrg} 99f220fa62Smrg 100f220fa62Smrg/*------------------------------------------------------------------------- 101f220fa62Smrg * surfpts - pass a desription of a surface map 102f220fa62Smrg *------------------------------------------------------------------------- 103f220fa62Smrg */ 104f220fa62Smrgvoid 105f220fa62SmrgBackend::surfpts( 106f220fa62Smrg long type, /* geometry, color, texture, normal */ 107f220fa62Smrg REAL *pts, /* control points */ 108f220fa62Smrg long ustride, /* distance to next point in u direction */ 109f220fa62Smrg long vstride, /* distance to next point in v direction */ 110f220fa62Smrg int uorder, /* u parametric order */ 111f220fa62Smrg int vorder, /* v parametric order */ 112f220fa62Smrg REAL ulo, /* u lower bound */ 113f220fa62Smrg REAL uhi, /* u upper bound */ 114f220fa62Smrg REAL vlo, /* v lower bound */ 115f220fa62Smrg REAL vhi ) /* v upper bound */ 116f220fa62Smrg{ 117f220fa62Smrg surfaceEvaluator.map2f( type,ulo,uhi,ustride,uorder,vlo,vhi,vstride,vorder,pts ); 118f220fa62Smrg surfaceEvaluator.enable( type ); 119f220fa62Smrg} 120f220fa62Smrg 121f220fa62Smrg/*------------------------------------------------------------------------- 122f220fa62Smrg * surfgrid - define a lattice of points with origin and offset 123f220fa62Smrg *------------------------------------------------------------------------- 124f220fa62Smrg */ 125f220fa62Smrgvoid 126f220fa62SmrgBackend::surfgrid( REAL u0, REAL u1, long nu, REAL v0, REAL v1, long nv ) 127f220fa62Smrg{ 128f220fa62Smrg surfaceEvaluator.mapgrid2f( nu, u0, u1, nv, v0, v1 ); 129f220fa62Smrg} 130f220fa62Smrg 131f220fa62Smrg/*------------------------------------------------------------------------- 132f220fa62Smrg * surfmesh - evaluate a mesh of points on lattice 133f220fa62Smrg *------------------------------------------------------------------------- 134f220fa62Smrg */ 135f220fa62Smrgvoid 136f220fa62SmrgBackend::surfmesh( long u, long v, long n, long m ) 137f220fa62Smrg{ 138f220fa62Smrg#ifndef NOWIREFRAME 139f220fa62Smrg if( wireframequads ) { 140f220fa62Smrg long v0, v1; 141f220fa62Smrg long u0f = u, u1f = u+n; 142f220fa62Smrg long v0f = v, v1f = v+m; 143f220fa62Smrg long parity = (u & 1); 144f220fa62Smrg 145f220fa62Smrg for( v0 = v0f, v1 = v0f++ ; v0<v1f; v0 = v1, v1++ ) { 146f220fa62Smrg surfaceEvaluator.bgnline(); 147f220fa62Smrg for( long u = u0f; u<=u1f; u++ ) { 148f220fa62Smrg if( parity ) { 149f220fa62Smrg surfaceEvaluator.evalpoint2i( u, v0 ); 150f220fa62Smrg surfaceEvaluator.evalpoint2i( u, v1 ); 151f220fa62Smrg } else { 152f220fa62Smrg surfaceEvaluator.evalpoint2i( u, v1 ); 153f220fa62Smrg surfaceEvaluator.evalpoint2i( u, v0 ); 154f220fa62Smrg } 155f220fa62Smrg parity = 1 - parity; 156f220fa62Smrg } 157f220fa62Smrg surfaceEvaluator.endline(); 158f220fa62Smrg } 159f220fa62Smrg } else { 160f220fa62Smrg surfaceEvaluator.mapmesh2f( N_MESHFILL, u, u+n, v, v+m ); 161f220fa62Smrg } 162f220fa62Smrg#else 163f220fa62Smrg if( wireframequads ) { 164f220fa62Smrg 165f220fa62Smrg surfaceEvaluator.mapmesh2f( N_MESHLINE, u, u+n, v, v+m ); 166f220fa62Smrg } else { 167f220fa62Smrg 168f220fa62Smrg surfaceEvaluator.mapmesh2f( N_MESHFILL, u, u+n, v, v+m ); 169f220fa62Smrg } 170f220fa62Smrg#endif 171f220fa62Smrg} 172f220fa62Smrg 173f220fa62Smrg/*------------------------------------------------------------------------- 174f220fa62Smrg * endsurf - postamble to surface 175f220fa62Smrg *------------------------------------------------------------------------- 176f220fa62Smrg */ 177f220fa62Smrgvoid 178f220fa62SmrgBackend::endsurf( void ) 179f220fa62Smrg{ 180f220fa62Smrg surfaceEvaluator.endmap2f(); 181f220fa62Smrg} 182f220fa62Smrg 183f220fa62Smrg/***************************************/ 184f220fa62Smrgvoid 185f220fa62SmrgBackend::bgntfan( void ) 186f220fa62Smrg{ 187f220fa62Smrg surfaceEvaluator.bgntfan(); 188f220fa62Smrg/* 189f220fa62Smrg if(wireframetris) 190f220fa62Smrg surfaceEvaluator.polymode( N_MESHLINE ); 191f220fa62Smrg else 192f220fa62Smrg surfaceEvaluator.polymode( N_MESHFILL ); 193f220fa62Smrg*/ 194f220fa62Smrg} 195f220fa62Smrg 196f220fa62Smrgvoid 197f220fa62SmrgBackend::endtfan( void ) 198f220fa62Smrg{ 199f220fa62Smrg surfaceEvaluator.endtfan(); 200f220fa62Smrg} 201f220fa62Smrg 202f220fa62Smrgvoid 203f220fa62SmrgBackend::bgnqstrip( void ) 204f220fa62Smrg{ 205f220fa62Smrg surfaceEvaluator.bgnqstrip(); 206f220fa62Smrg/* 207f220fa62Smrg if(wireframequads) 208f220fa62Smrg surfaceEvaluator.polymode( N_MESHLINE ); 209f220fa62Smrg else 210f220fa62Smrg surfaceEvaluator.polymode( N_MESHFILL ); 211f220fa62Smrg*/ 212f220fa62Smrg} 213f220fa62Smrg 214f220fa62Smrgvoid 215f220fa62SmrgBackend::endqstrip( void ) 216f220fa62Smrg{ 217f220fa62Smrg surfaceEvaluator.endqstrip(); 218f220fa62Smrg} 219f220fa62Smrg 220f220fa62Smrgvoid 221f220fa62SmrgBackend::evalUStrip(int n_upper, REAL v_upper, REAL* upper_val, 222f220fa62Smrg int n_lower, REAL v_lower, REAL* lower_val 223f220fa62Smrg ) 224f220fa62Smrg{ 225f220fa62Smrg surfaceEvaluator.evalUStrip(n_upper, v_upper, upper_val, 226f220fa62Smrg n_lower, v_lower, lower_val); 227f220fa62Smrg} 228f220fa62Smrg 229f220fa62Smrgvoid 230f220fa62SmrgBackend::evalVStrip(int n_left, REAL u_left, REAL* left_val, 231f220fa62Smrg int n_right, REAL u_right, REAL* right_val 232f220fa62Smrg ) 233f220fa62Smrg{ 234f220fa62Smrg surfaceEvaluator.evalVStrip(n_left, u_left, left_val, 235f220fa62Smrg n_right, u_right, right_val); 236f220fa62Smrg} 237f220fa62Smrg 238f220fa62Smrg/***************************************/ 239f220fa62Smrg 240f220fa62Smrg 241f220fa62Smrg/*------------------------------------------------------------------------- 242f220fa62Smrg * bgntmesh - preamble to a triangle mesh 243f220fa62Smrg *------------------------------------------------------------------------- 244f220fa62Smrg */ 245f220fa62Smrgvoid 246f220fa62SmrgBackend::bgntmesh( const char * ) 247f220fa62Smrg{ 248f220fa62Smrg#ifndef NOWIREFRAME 249f220fa62Smrg 250f220fa62Smrg meshindex = 0; /* I think these need to be initialized to zero */ 251f220fa62Smrg npts = 0; 252f220fa62Smrg 253f220fa62Smrg if( !wireframetris ) { 254f220fa62Smrg surfaceEvaluator.bgntmesh(); 255f220fa62Smrg } 256f220fa62Smrg#else 257f220fa62Smrg 258f220fa62Smrg if( wireframetris ) { 259f220fa62Smrg surfaceEvaluator.bgntmesh(); 260f220fa62Smrg surfaceEvaluator.polymode( N_MESHLINE ); 261f220fa62Smrg } else { 262f220fa62Smrg surfaceEvaluator.bgntmesh(); 263f220fa62Smrg surfaceEvaluator.polymode( N_MESHFILL ); 264f220fa62Smrg } 265f220fa62Smrg#endif 266f220fa62Smrg} 267f220fa62Smrg 268f220fa62Smrgvoid 269f220fa62SmrgBackend::tmeshvert( GridTrimVertex *v ) 270f220fa62Smrg{ 271f220fa62Smrg if( v->isGridVert() ) { 272f220fa62Smrg tmeshvert( v->g ); 273f220fa62Smrg } else { 274f220fa62Smrg tmeshvert( v->t ); 275f220fa62Smrg } 276f220fa62Smrg} 277f220fa62Smrg 278f220fa62Smrgvoid 279f220fa62SmrgBackend::tmeshvertNOGE(TrimVertex *t) 280f220fa62Smrg{ 281f220fa62Smrg// surfaceEvaluator.inDoEvalCoord2NOGE( t->param[0], t->param[1], temp, ttt); 282f220fa62Smrg#ifdef USE_OPTTT 283f220fa62Smrg surfaceEvaluator.inDoEvalCoord2NOGE( t->param[0], t->param[1], t->cache_point, t->cache_normal); 284f220fa62Smrg#endif 285f220fa62Smrg} 286f220fa62Smrg 287f220fa62Smrg//opt for a line with the same u. 288f220fa62Smrgvoid 289f220fa62SmrgBackend::tmeshvertNOGE_BU(TrimVertex *t) 290f220fa62Smrg{ 291f220fa62Smrg#ifdef USE_OPTTT 292f220fa62Smrg surfaceEvaluator.inDoEvalCoord2NOGE_BU( t->param[0], t->param[1], t->cache_point, t->cache_normal); 293f220fa62Smrg#endif 294f220fa62Smrg} 295f220fa62Smrg 296f220fa62Smrg//opt for a line with the same v. 297f220fa62Smrgvoid 298f220fa62SmrgBackend::tmeshvertNOGE_BV(TrimVertex *t) 299f220fa62Smrg{ 300f220fa62Smrg#ifdef USE_OPTTT 301f220fa62Smrg surfaceEvaluator.inDoEvalCoord2NOGE_BV( t->param[0], t->param[1], t->cache_point, t->cache_normal); 302f220fa62Smrg#endif 303f220fa62Smrg} 304f220fa62Smrg 305f220fa62Smrgvoid 306f220fa62SmrgBackend::preEvaluateBU(REAL u) 307f220fa62Smrg{ 308f220fa62Smrg surfaceEvaluator.inPreEvaluateBU_intfac(u); 309f220fa62Smrg} 310f220fa62Smrg 311f220fa62Smrgvoid 312f220fa62SmrgBackend::preEvaluateBV(REAL v) 313f220fa62Smrg{ 314f220fa62Smrg surfaceEvaluator.inPreEvaluateBV_intfac(v); 315f220fa62Smrg} 316f220fa62Smrg 317f220fa62Smrg 318f220fa62Smrg/*------------------------------------------------------------------------- 319f220fa62Smrg * tmeshvert - evaluate a point on a triangle mesh 320f220fa62Smrg *------------------------------------------------------------------------- 321f220fa62Smrg */ 322f220fa62Smrgvoid 323f220fa62SmrgBackend::tmeshvert( TrimVertex *t ) 324f220fa62Smrg{ 325f220fa62Smrg 326f220fa62Smrg#ifndef NOWIREFRAME 327f220fa62Smrg const long nuid = t->nuid; 328f220fa62Smrg#endif 329f220fa62Smrg const REAL u = t->param[0]; 330f220fa62Smrg const REAL v = t->param[1]; 331f220fa62Smrg 332f220fa62Smrg#ifndef NOWIREFRAME 333f220fa62Smrg npts++; 334f220fa62Smrg if( wireframetris ) { 335f220fa62Smrg if( npts >= 3 ) { 336f220fa62Smrg surfaceEvaluator.bgnclosedline(); 337f220fa62Smrg if( mesh[0][2] == 0 ) 338f220fa62Smrg surfaceEvaluator.evalcoord2f( mesh[0][3], mesh[0][0], mesh[0][1] ); 339f220fa62Smrg else 340f220fa62Smrg surfaceEvaluator.evalpoint2i( (long) mesh[0][0], (long) mesh[0][1] ); 341f220fa62Smrg if( mesh[1][2] == 0 ) 342f220fa62Smrg surfaceEvaluator.evalcoord2f( mesh[1][3], mesh[1][0], mesh[1][1] ); 343f220fa62Smrg else 344f220fa62Smrg surfaceEvaluator.evalpoint2i( (long) mesh[1][0], (long) mesh[1][1] ); 345f220fa62Smrg surfaceEvaluator.evalcoord2f( nuid, u, v ); 346f220fa62Smrg surfaceEvaluator.endclosedline(); 347f220fa62Smrg } 348f220fa62Smrg mesh[meshindex][0] = u; 349f220fa62Smrg mesh[meshindex][1] = v; 350f220fa62Smrg mesh[meshindex][2] = 0; 351f220fa62Smrg mesh[meshindex][3] = nuid; 352f220fa62Smrg meshindex = (meshindex+1) % 2; 353f220fa62Smrg } else { 354f220fa62Smrg surfaceEvaluator.evalcoord2f( nuid, u, v ); 355f220fa62Smrg } 356f220fa62Smrg#else 357f220fa62Smrg 358f220fa62Smrg surfaceEvaluator.evalcoord2f( 0, u, v ); 359f220fa62Smrg//for uninitial memory read surfaceEvaluator.evalcoord2f( nuid, u, v ); 360f220fa62Smrg#endif 361f220fa62Smrg} 362f220fa62Smrg 363f220fa62Smrg//the same as tmeshvert(trimvertex), for efficiency purpose 364f220fa62Smrgvoid 365f220fa62SmrgBackend::tmeshvert( REAL u, REAL v ) 366f220fa62Smrg{ 367f220fa62Smrg#ifndef NOWIREFRAME 368f220fa62Smrg const long nuid = 0; 369f220fa62Smrg 370f220fa62Smrg npts++; 371f220fa62Smrg if( wireframetris ) { 372f220fa62Smrg if( npts >= 3 ) { 373f220fa62Smrg surfaceEvaluator.bgnclosedline(); 374f220fa62Smrg if( mesh[0][2] == 0 ) 375f220fa62Smrg surfaceEvaluator.evalcoord2f( mesh[0][3], mesh[0][0], mesh[0][1] ); 376f220fa62Smrg else 377f220fa62Smrg surfaceEvaluator.evalpoint2i( (long) mesh[0][0], (long) mesh[0][1] ); 378f220fa62Smrg if( mesh[1][2] == 0 ) 379f220fa62Smrg surfaceEvaluator.evalcoord2f( mesh[1][3], mesh[1][0], mesh[1][1] ); 380f220fa62Smrg else 381f220fa62Smrg surfaceEvaluator.evalpoint2i( (long) mesh[1][0], (long) mesh[1][1] ); 382f220fa62Smrg surfaceEvaluator.evalcoord2f( nuid, u, v ); 383f220fa62Smrg surfaceEvaluator.endclosedline(); 384f220fa62Smrg } 385f220fa62Smrg mesh[meshindex][0] = u; 386f220fa62Smrg mesh[meshindex][1] = v; 387f220fa62Smrg mesh[meshindex][2] = 0; 388f220fa62Smrg mesh[meshindex][3] = nuid; 389f220fa62Smrg meshindex = (meshindex+1) % 2; 390f220fa62Smrg } else { 391f220fa62Smrg surfaceEvaluator.evalcoord2f( nuid, u, v ); 392f220fa62Smrg } 393f220fa62Smrg#else 394f220fa62Smrg 395f220fa62Smrg surfaceEvaluator.evalcoord2f( 0, u, v ); 396f220fa62Smrg#endif 397f220fa62Smrg} 398f220fa62Smrg 399f220fa62Smrg/*------------------------------------------------------------------------- 400f220fa62Smrg * tmeshvert - evaluate a grid point of a triangle mesh 401f220fa62Smrg *------------------------------------------------------------------------- 402f220fa62Smrg */ 403f220fa62Smrgvoid 404f220fa62SmrgBackend::tmeshvert( GridVertex *g ) 405f220fa62Smrg{ 406f220fa62Smrg const long u = g->gparam[0]; 407f220fa62Smrg const long v = g->gparam[1]; 408f220fa62Smrg 409f220fa62Smrg#ifndef NOWIREFRAME 410f220fa62Smrg npts++; 411f220fa62Smrg if( wireframetris ) { 412f220fa62Smrg if( npts >= 3 ) { 413f220fa62Smrg surfaceEvaluator.bgnclosedline(); 414f220fa62Smrg if( mesh[0][2] == 0 ) 415f220fa62Smrg surfaceEvaluator.evalcoord2f( (long) mesh[0][3], mesh[0][0], mesh[0][1] ); 416f220fa62Smrg else 417f220fa62Smrg surfaceEvaluator.evalpoint2i( (long) mesh[0][0], (long) mesh[0][1] ); 418f220fa62Smrg if( mesh[1][2] == 0 ) 419f220fa62Smrg surfaceEvaluator.evalcoord2f( (long) mesh[1][3], mesh[1][0], mesh[1][1] ); 420f220fa62Smrg else 421f220fa62Smrg surfaceEvaluator.evalpoint2i( (long) mesh[1][0], (long) mesh[1][1] ); 422f220fa62Smrg surfaceEvaluator.evalpoint2i( u, v ); 423f220fa62Smrg surfaceEvaluator.endclosedline(); 424f220fa62Smrg } 425f220fa62Smrg mesh[meshindex][0] = u; 426f220fa62Smrg mesh[meshindex][1] = v; 427f220fa62Smrg mesh[meshindex][2] = 1; 428f220fa62Smrg meshindex = (meshindex+1) % 2; 429f220fa62Smrg } else { 430f220fa62Smrg surfaceEvaluator.evalpoint2i( u, v ); 431f220fa62Smrg } 432f220fa62Smrg#else 433f220fa62Smrg surfaceEvaluator.evalpoint2i( u, v ); 434f220fa62Smrg#endif 435f220fa62Smrg} 436f220fa62Smrg 437f220fa62Smrg/*------------------------------------------------------------------------- 438f220fa62Smrg * swaptmesh - perform a swap of the triangle mesh pointers 439f220fa62Smrg *------------------------------------------------------------------------- 440f220fa62Smrg */ 441f220fa62Smrgvoid 442f220fa62SmrgBackend::swaptmesh( void ) 443f220fa62Smrg{ 444f220fa62Smrg#ifndef NOWIREFRAME 445f220fa62Smrg if( wireframetris ) { 446f220fa62Smrg meshindex = 1 - meshindex; 447f220fa62Smrg } else { 448f220fa62Smrg surfaceEvaluator.swaptmesh(); 449f220fa62Smrg } 450f220fa62Smrg#else 451f220fa62Smrg surfaceEvaluator.swaptmesh(); 452f220fa62Smrg#endif 453f220fa62Smrg} 454f220fa62Smrg 455f220fa62Smrg/*------------------------------------------------------------------------- 456f220fa62Smrg * endtmesh - postamble to triangle mesh 457f220fa62Smrg *------------------------------------------------------------------------- 458f220fa62Smrg */ 459f220fa62Smrgvoid 460f220fa62SmrgBackend::endtmesh( void ) 461f220fa62Smrg{ 462f220fa62Smrg#ifndef NOWIREFRAME 463f220fa62Smrg if( ! wireframetris ) 464f220fa62Smrg surfaceEvaluator.endtmesh(); 465f220fa62Smrg#else 466f220fa62Smrg surfaceEvaluator.endtmesh(); 467f220fa62Smrg/* surfaceEvaluator.polymode( N_MESHFILL );*/ 468f220fa62Smrg#endif 469f220fa62Smrg} 470f220fa62Smrg 471f220fa62Smrg 472f220fa62Smrg/*------------------------------------------------------------------------- 473f220fa62Smrg * bgnoutline - preamble to outlined rendering 474f220fa62Smrg *------------------------------------------------------------------------- 475f220fa62Smrg */ 476f220fa62Smrgvoid 477f220fa62SmrgBackend::bgnoutline( void ) 478f220fa62Smrg{ 479f220fa62Smrg surfaceEvaluator.bgnline(); 480f220fa62Smrg} 481f220fa62Smrg 482f220fa62Smrg/*------------------------------------------------------------------------- 483f220fa62Smrg * linevert - evaluate a point on an outlined contour 484f220fa62Smrg *------------------------------------------------------------------------- 485f220fa62Smrg */ 486f220fa62Smrgvoid 487f220fa62SmrgBackend::linevert( TrimVertex *t ) 488f220fa62Smrg{ 489f220fa62Smrg surfaceEvaluator.evalcoord2f( t->nuid, t->param[0], t->param[1] ); 490f220fa62Smrg} 491f220fa62Smrg 492f220fa62Smrg/*------------------------------------------------------------------------- 493f220fa62Smrg * linevert - evaluate a grid point of an outlined contour 494f220fa62Smrg *------------------------------------------------------------------------- 495f220fa62Smrg */ 496f220fa62Smrgvoid 497f220fa62SmrgBackend::linevert( GridVertex *g ) 498f220fa62Smrg{ 499f220fa62Smrg surfaceEvaluator.evalpoint2i( g->gparam[0], g->gparam[1] ); 500f220fa62Smrg} 501f220fa62Smrg 502f220fa62Smrg/*------------------------------------------------------------------------- 503f220fa62Smrg * endoutline - postamble to outlined rendering 504f220fa62Smrg *------------------------------------------------------------------------- 505f220fa62Smrg */ 506f220fa62Smrgvoid 507f220fa62SmrgBackend::endoutline( void ) 508f220fa62Smrg{ 509f220fa62Smrg surfaceEvaluator.endline(); 510f220fa62Smrg} 511f220fa62Smrg 512f220fa62Smrg/*------------------------------------------------------------------------- 513f220fa62Smrg * triangle - output a triangle 514f220fa62Smrg *------------------------------------------------------------------------- 515f220fa62Smrg */ 516f220fa62Smrgvoid 517f220fa62SmrgBackend::triangle( TrimVertex *a, TrimVertex *b, TrimVertex *c ) 518f220fa62Smrg{ 519f220fa62Smrg/* bgntmesh( "spittriangle" );*/ 520f220fa62Smrg bgntfan(); 521f220fa62Smrg tmeshvert( a ); 522f220fa62Smrg tmeshvert( b ); 523f220fa62Smrg tmeshvert( c ); 524f220fa62Smrg endtfan(); 525f220fa62Smrg/* endtmesh();*/ 526f220fa62Smrg} 527f220fa62Smrg 528f220fa62Smrgvoid 529f220fa62SmrgBackend::bgncurv( void ) 530f220fa62Smrg{ 531f220fa62Smrg curveEvaluator.bgnmap1f( 0 ); 532f220fa62Smrg} 533f220fa62Smrg 534f220fa62Smrgvoid 535f220fa62SmrgBackend::segment( REAL ulo, REAL uhi ) 536f220fa62Smrg{ 537f220fa62Smrg curveEvaluator.domain1f( ulo, uhi ); 538f220fa62Smrg} 539f220fa62Smrg 540f220fa62Smrgvoid 541f220fa62SmrgBackend::curvpts( 542f220fa62Smrg long type, /* geometry, color, texture, normal */ 543f220fa62Smrg REAL *pts, /* control points */ 544f220fa62Smrg long stride, /* distance to next point */ 545f220fa62Smrg int order, /* parametric order */ 546f220fa62Smrg REAL ulo, /* lower parametric bound */ 547f220fa62Smrg REAL uhi ) /* upper parametric bound */ 548f220fa62Smrg 549f220fa62Smrg{ 550f220fa62Smrg curveEvaluator.map1f( type, ulo, uhi, stride, order, pts ); 551f220fa62Smrg curveEvaluator.enable( type ); 552f220fa62Smrg} 553f220fa62Smrg 554f220fa62Smrgvoid 555f220fa62SmrgBackend::curvgrid( REAL u0, REAL u1, long nu ) 556f220fa62Smrg{ 557f220fa62Smrg curveEvaluator.mapgrid1f( nu, u0, u1 ); 558f220fa62Smrg} 559f220fa62Smrg 560f220fa62Smrgvoid 561f220fa62SmrgBackend::curvmesh( long from, long n ) 562f220fa62Smrg{ 563f220fa62Smrg curveEvaluator.mapmesh1f( N_MESHFILL, from, from+n ); 564f220fa62Smrg} 565f220fa62Smrg 566f220fa62Smrgvoid 567f220fa62SmrgBackend::curvpt(REAL u) 568f220fa62Smrg{ 569f220fa62Smrg curveEvaluator.evalcoord1f( 0, u ); 570f220fa62Smrg} 571f220fa62Smrg 572f220fa62Smrgvoid 573f220fa62SmrgBackend::bgnline( void ) 574f220fa62Smrg{ 575f220fa62Smrg curveEvaluator.bgnline(); 576f220fa62Smrg} 577f220fa62Smrg 578f220fa62Smrgvoid 579f220fa62SmrgBackend::endline( void ) 580f220fa62Smrg{ 581f220fa62Smrg curveEvaluator.endline(); 582f220fa62Smrg} 583f220fa62Smrg 584f220fa62Smrgvoid 585f220fa62SmrgBackend::endcurv( void ) 586f220fa62Smrg{ 587f220fa62Smrg curveEvaluator.endmap1f(); 588f220fa62Smrg} 589