Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygencoveandtiler.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 * coveandtiler.c++ 00037 * 00038 */ 00039 00040 #include "glimports.h" 00041 #include "myassert.h" 00042 #include "mystdio.h" 00043 #include "coveandtiler.h" 00044 #include "gridvertex.h" 00045 #include "gridtrimvertex.h" 00046 #include "uarray.h" 00047 #include "backend.h" 00048 00049 00050 const int CoveAndTiler::MAXSTRIPSIZE = 1000; 00051 00052 CoveAndTiler::CoveAndTiler( Backend& b ) 00053 : backend( b ) 00054 { } 00055 00056 CoveAndTiler::~CoveAndTiler( void ) 00057 { } 00058 00059 inline void 00060 CoveAndTiler::output( GridVertex &gv ) 00061 { 00062 backend.tmeshvert( &gv ); 00063 } 00064 00065 inline void 00066 CoveAndTiler::output( TrimVertex *tv ) 00067 { 00068 backend.tmeshvert( tv ); 00069 } 00070 00071 inline void 00072 CoveAndTiler::output( GridTrimVertex& g ) 00073 { 00074 backend.tmeshvert( &g ); 00075 } 00076 00077 void 00078 CoveAndTiler::coveAndTile( void ) 00079 { 00080 long ustart = (top.ustart >= bot.ustart) ? top.ustart : bot.ustart; 00081 long uend = (top.uend <= bot.uend) ? top.uend : bot.uend; 00082 if( ustart <= uend ) { 00083 tile( bot.vindex, ustart, uend ); 00084 if( top.ustart >= bot.ustart ) 00085 coveUpperLeft(); 00086 else 00087 coveLowerLeft(); 00088 00089 if( top.uend <= bot.uend ) 00090 coveUpperRight(); 00091 else 00092 coveLowerRight(); 00093 } else { 00094 TrimVertex blv, tlv, *bl, *tl; 00095 GridTrimVertex bllv, tllv; 00096 TrimVertex *lf = left.first(); 00097 TrimVertex *ll = left.last(); 00098 if( lf->param[0] >= ll->param[0] ) { 00099 blv.param[0] = lf->param[0]; 00100 blv.param[1] = ll->param[1]; 00101 blv.nuid = 0; // XXX 00102 assert( blv.param[1] == bot.vval ); 00103 bl = &blv; 00104 tl = lf; 00105 tllv.set( lf ); 00106 if( ll->param[0] > uarray.uarray[top.ustart-1] ) { 00107 bllv.set( ll ); 00108 assert( ll->param[0] <= uarray.uarray[bot.ustart] ); 00109 } else { 00110 bllv.set( top.ustart-1, bot.vindex ); 00111 } 00112 coveUpperLeftNoGrid( bl ); 00113 } else { 00114 tlv.param[0] = ll->param[0]; 00115 tlv.param[1] = lf->param[1]; 00116 tlv.nuid = 0; // XXX 00117 assert( tlv.param[1] == top.vval ); 00118 tl = &tlv; 00119 bl = ll; 00120 bllv.set( ll ); 00121 if( lf->param[0] > uarray.uarray[bot.ustart-1] ) { 00122 assert( lf->param[0] <= uarray.uarray[bot.ustart] ); 00123 tllv.set( lf ); 00124 } else { 00125 tllv.set( bot.ustart-1, top.vindex ); 00126 } 00127 coveLowerLeftNoGrid( tl ); 00128 } 00129 00130 TrimVertex brv, trv, *br, *tr; 00131 GridTrimVertex brrv, trrv; 00132 TrimVertex *rf = right.first(); 00133 TrimVertex *rl = right.last(); 00134 00135 if( rf->param[0] <= rl->param[0] ) { 00136 brv.param[0] = rf->param[0]; 00137 brv.param[1] = rl->param[1]; 00138 brv.nuid = 0; // XXX 00139 assert( brv.param[1] == bot.vval ); 00140 br = &brv; 00141 tr = rf; 00142 trrv.set( rf ); 00143 if( rl->param[0] < uarray.uarray[top.uend+1] ) { 00144 assert( rl->param[0] >= uarray.uarray[top.uend] ); 00145 brrv.set( rl ); 00146 } else { 00147 brrv.set( top.uend+1, bot.vindex ); 00148 } 00149 coveUpperRightNoGrid( br ); 00150 } else { 00151 trv.param[0] = rl->param[0]; 00152 trv.param[1] = rf->param[1]; 00153 trv.nuid = 0; // XXX 00154 assert( trv.param[1] == top.vval ); 00155 tr = &trv; 00156 br = rl; 00157 brrv.set( rl ); 00158 if( rf->param[0] < uarray.uarray[bot.uend+1] ) { 00159 assert( rf->param[0] >= uarray.uarray[bot.uend] ); 00160 trrv.set( rf ); 00161 } else { 00162 trrv.set( bot.uend+1, top.vindex ); 00163 } 00164 coveLowerRightNoGrid( tr ); 00165 } 00166 00167 backend.bgntmesh( "doit" ); 00168 output(trrv); 00169 output(tllv); 00170 output( tr ); 00171 output( tl ); 00172 output( br ); 00173 output( bl ); 00174 output(brrv); 00175 output(bllv); 00176 backend.endtmesh(); 00177 } 00178 } 00179 00180 void 00181 CoveAndTiler::tile( long vindex, long ustart, long uend ) 00182 { 00183 long numsteps = uend - ustart; 00184 00185 if( numsteps == 0 ) return; 00186 00187 if( numsteps > MAXSTRIPSIZE ) { 00188 long umid = ustart + (uend - ustart) / 2; 00189 tile( vindex, ustart, umid ); 00190 tile( vindex, umid, uend ); 00191 } else { 00192 backend.surfmesh( ustart, vindex-1, numsteps, 1 ); 00193 } 00194 } 00195 00196 void 00197 CoveAndTiler::coveUpperRight( void ) 00198 { 00199 GridVertex tgv( top.uend, top.vindex ); 00200 GridVertex gv( top.uend, bot.vindex ); 00201 00202 right.first(); 00203 backend.bgntmesh( "coveUpperRight" ); 00204 output( right.next() ); 00205 output( tgv ); 00206 backend.swaptmesh(); 00207 output( gv ); 00208 coveUR(); 00209 backend.endtmesh(); 00210 } 00211 00212 void 00213 CoveAndTiler::coveUpperRightNoGrid( TrimVertex* br ) 00214 { 00215 backend.bgntmesh( "coveUpperRight" ); 00216 output( right.first() ); 00217 output( right.next() ); 00218 backend.swaptmesh(); 00219 output( br ); 00220 coveUR(); 00221 backend.endtmesh(); 00222 } 00223 00224 void 00225 CoveAndTiler::coveUR( ) 00226 { 00227 GridVertex gv( top.uend, bot.vindex ); 00228 TrimVertex *vert = right.next(); 00229 if( vert == NULL ) return; 00230 00231 assert( vert->param[0] >= uarray.uarray[gv.gparam[0]] ); 00232 00233 if( gv.nextu() >= bot.uend ) { 00234 for( ; vert; vert = right.next() ) { 00235 output( vert ); 00236 backend.swaptmesh(); 00237 } 00238 } else while( 1 ) { 00239 if( vert->param[0] < uarray.uarray[gv.gparam[0]] ) { 00240 output( vert ); 00241 backend.swaptmesh(); 00242 vert = right.next(); 00243 if( vert == NULL ) break; 00244 } else { 00245 backend.swaptmesh(); 00246 output( gv ); 00247 if( gv.nextu() == bot.uend ) { 00248 for( ; vert; vert = right.next() ) { 00249 output( vert ); 00250 backend.swaptmesh(); 00251 } 00252 break; 00253 } 00254 } 00255 } 00256 } 00257 00258 void 00259 CoveAndTiler::coveUpperLeft( void ) 00260 { 00261 GridVertex tgv( top.ustart, top.vindex ); 00262 GridVertex gv( top.ustart, bot.vindex ); 00263 00264 left.first(); 00265 backend.bgntmesh( "coveUpperLeft" ); 00266 output( tgv ); 00267 output( left.next() ); 00268 output( gv ); 00269 backend.swaptmesh(); 00270 coveUL(); 00271 backend.endtmesh(); 00272 } 00273 00274 void 00275 CoveAndTiler::coveUpperLeftNoGrid( TrimVertex* bl ) 00276 { 00277 backend.bgntmesh( "coveUpperLeftNoGrid" ); 00278 output( left.first() ); 00279 output( left.next() ); 00280 output( bl ); 00281 backend.swaptmesh(); 00282 coveUL(); 00283 backend.endtmesh(); 00284 } 00285 00286 void 00287 CoveAndTiler::coveUL() 00288 { 00289 GridVertex gv( top.ustart, bot.vindex ); 00290 TrimVertex *vert = left.next(); 00291 if( vert == NULL ) return; 00292 assert( vert->param[0] <= uarray.uarray[gv.gparam[0]] ); 00293 00294 if( gv.prevu() <= bot.ustart ) { 00295 for( ; vert; vert = left.next() ) { 00296 backend.swaptmesh(); 00297 output( vert ); 00298 } 00299 } else while( 1 ) { 00300 if( vert->param[0] > uarray.uarray[gv.gparam[0]] ) { 00301 backend.swaptmesh(); 00302 output( vert ); 00303 vert = left.next(); 00304 if( vert == NULL ) break; 00305 } else { 00306 output( gv ); 00307 backend.swaptmesh(); 00308 if( gv.prevu() == bot.ustart ) { 00309 for( ; vert; vert = left.next() ) { 00310 backend.swaptmesh(); 00311 output( vert ); 00312 } 00313 break; 00314 } 00315 } 00316 } 00317 } 00318 00319 void 00320 CoveAndTiler::coveLowerLeft( void ) 00321 { 00322 GridVertex bgv( bot.ustart, bot.vindex ); 00323 GridVertex gv( bot.ustart, top.vindex ); 00324 00325 left.last(); 00326 backend.bgntmesh( "coveLowerLeft" ); 00327 output( left.prev() ); 00328 output( bgv ); 00329 backend.swaptmesh(); 00330 output( gv ); 00331 coveLL(); 00332 backend.endtmesh(); 00333 } 00334 00335 void 00336 CoveAndTiler::coveLowerLeftNoGrid( TrimVertex* tl ) 00337 { 00338 backend.bgntmesh( "coveLowerLeft" ); 00339 output( left.last() ); 00340 output( left.prev() ); 00341 backend.swaptmesh(); 00342 output( tl ); 00343 coveLL( ); 00344 backend.endtmesh(); 00345 } 00346 00347 void 00348 CoveAndTiler::coveLL() 00349 { 00350 GridVertex gv( bot.ustart, top.vindex ); 00351 TrimVertex *vert = left.prev(); 00352 if( vert == NULL ) return; 00353 assert( vert->param[0] <= uarray.uarray[gv.gparam[0]] ); 00354 00355 if( gv.prevu() <= top.ustart ) { 00356 for( ; vert; vert = left.prev() ) { 00357 output( vert ); 00358 backend.swaptmesh(); 00359 } 00360 } else while( 1 ) { 00361 if( vert->param[0] > uarray.uarray[gv.gparam[0]] ){ 00362 output( vert ); 00363 backend.swaptmesh(); 00364 vert = left.prev(); 00365 if( vert == NULL ) break; 00366 } else { 00367 backend.swaptmesh(); 00368 output( gv ); 00369 if( gv.prevu() == top.ustart ) { 00370 for( ; vert; vert = left.prev() ) { 00371 output( vert ); 00372 backend.swaptmesh(); 00373 } 00374 break; 00375 } 00376 } 00377 } 00378 } 00379 00380 void 00381 CoveAndTiler::coveLowerRight( void ) 00382 { 00383 GridVertex bgv( bot.uend, bot.vindex ); 00384 GridVertex gv( bot.uend, top.vindex ); 00385 00386 right.last(); 00387 backend.bgntmesh( "coveLowerRight" ); 00388 output( bgv ); 00389 output( right.prev() ); 00390 output( gv ); 00391 backend.swaptmesh(); 00392 coveLR(); 00393 backend.endtmesh( ); 00394 } 00395 00396 void 00397 CoveAndTiler::coveLowerRightNoGrid( TrimVertex* tr ) 00398 { 00399 backend.bgntmesh( "coveLowerRIght" ); 00400 output( right.last() ); 00401 output( right.prev() ); 00402 output( tr ); 00403 backend.swaptmesh(); 00404 coveLR(); 00405 backend.endtmesh(); 00406 } 00407 00408 void 00409 CoveAndTiler::coveLR( ) 00410 { 00411 GridVertex gv( bot.uend, top.vindex ); 00412 TrimVertex *vert = right.prev(); 00413 if( vert == NULL ) return; 00414 assert( vert->param[0] >= uarray.uarray[gv.gparam[0]] ); 00415 00416 if( gv.nextu() >= top.uend ) { 00417 for( ; vert; vert = right.prev() ) { 00418 backend.swaptmesh(); 00419 output( vert ); 00420 } 00421 } else while( 1 ) { 00422 if( vert->param[0] < uarray.uarray[gv.gparam[0]] ) { 00423 backend.swaptmesh(); 00424 output( vert ); 00425 vert = right.prev(); 00426 if( vert == NULL ) break; 00427 } else { 00428 output( gv ); 00429 backend.swaptmesh(); 00430 if( gv.nextu() == top.uend ) { 00431 for( ; vert; vert = right.prev() ) { 00432 backend.swaptmesh(); 00433 output( vert ); 00434 } 00435 break; 00436 } 00437 } 00438 } 00439 } 00440 Generated on Sun May 27 2012 04:23:39 for ReactOS by
1.7.6.1
|