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

t_dd_rendertmp.h
Go to the documentation of this file.
00001 
00002 /*
00003  * Mesa 3-D graphics library
00004  * Version:  3.5
00005  *
00006  * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
00007  *
00008  * Permission is hereby granted, free of charge, to any person obtaining a
00009  * copy of this software and associated documentation files (the "Software"),
00010  * to deal in the Software without restriction, including without limitation
00011  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00012  * and/or sell copies of the Software, and to permit persons to whom the
00013  * Software is furnished to do so, subject to the following conditions:
00014  *
00015  * The above copyright notice and this permission notice shall be included
00016  * in all copies or substantial portions of the Software.
00017  *
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00020  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00021  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00022  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00023  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00024  *
00025  * Authors:
00026  *    Keith Whitwell <keith@tungstengraphics.com>
00027  */
00028 
00029 
00030 #ifndef POSTFIX
00031 #define POSTFIX
00032 #endif
00033 
00034 #ifndef INIT
00035 #define INIT(x)
00036 #endif
00037 
00038 #ifndef NEED_EDGEFLAG_SETUP
00039 #define NEED_EDGEFLAG_SETUP 0
00040 #define EDGEFLAG_GET(a) 0
00041 #define EDGEFLAG_SET(a,b) (void)b
00042 #endif
00043 
00044 #ifndef RESET_STIPPLE
00045 #define RESET_STIPPLE
00046 #endif
00047 
00048 #ifndef RESET_OCCLUSION
00049 #define RESET_OCCLUSION
00050 #endif
00051 
00052 #ifndef TEST_PRIM_END
00053 #define TEST_PRIM_END(flags) (flags & PRIM_END)
00054 #define TEST_PRIM_BEGIN(flags) (flags & PRIM_BEGIN)
00055 #define TEST_PRIM_PARITY(flags) (flags & PRIM_PARITY)
00056 #endif
00057 
00058 #ifndef ELT
00059 #define ELT(x) x
00060 #endif
00061 
00062 #ifndef RENDER_TAB_QUALIFIER
00063 #define RENDER_TAB_QUALIFIER static
00064 #endif
00065 
00066 static void TAG(render_points)( GLcontext *ctx,
00067                 GLuint start,
00068                 GLuint count,
00069                 GLuint flags )
00070 {
00071    LOCAL_VARS;
00072    (void) flags;
00073 
00074    RESET_OCCLUSION;
00075    INIT(GL_POINTS);
00076    RENDER_POINTS( start, count );
00077    POSTFIX;
00078 }
00079 
00080 static void TAG(render_lines)( GLcontext *ctx,
00081                    GLuint start,
00082                    GLuint count,
00083                    GLuint flags )
00084 {
00085    GLuint j;
00086    LOCAL_VARS;
00087    (void) flags;
00088 
00089    RESET_OCCLUSION;
00090    INIT(GL_LINES);
00091    for (j=start+1; j<count; j+=2 ) {
00092       RENDER_LINE( ELT(j-1), ELT(j) );
00093       RESET_STIPPLE;
00094    }
00095    POSTFIX;
00096 }
00097 
00098 
00099 static void TAG(render_line_strip)( GLcontext *ctx,
00100                     GLuint start,
00101                     GLuint count,
00102                     GLuint flags )
00103 {
00104    GLuint j;
00105    LOCAL_VARS;
00106    (void) flags;
00107 
00108    RESET_OCCLUSION;
00109    INIT(GL_LINE_STRIP);
00110 
00111    for (j=start+1; j<count; j++ )
00112       RENDER_LINE( ELT(j-1), ELT(j) );
00113 
00114    if (TEST_PRIM_END(flags))
00115       RESET_STIPPLE;
00116 
00117    POSTFIX;
00118 }
00119 
00120 
00121 static void TAG(render_line_loop)( GLcontext *ctx,
00122                    GLuint start,
00123                    GLuint count,
00124                    GLuint flags )
00125 {
00126    GLuint i;
00127    LOCAL_VARS;
00128 
00129    (void) flags;
00130 
00131    RESET_OCCLUSION;
00132    INIT(GL_LINE_LOOP);
00133 
00134    if (start+1 < count) {
00135       if (TEST_PRIM_BEGIN(flags)) {
00136      RENDER_LINE( ELT(start), ELT(start+1) );
00137       }
00138 
00139       for ( i = start+2 ; i < count ; i++) {
00140      RENDER_LINE( ELT(i-1), ELT(i) );
00141       }
00142 
00143       if ( TEST_PRIM_END(flags)) {
00144      RENDER_LINE( ELT(count-1), ELT(start) );
00145      RESET_STIPPLE;
00146       }
00147    }
00148 
00149    POSTFIX;
00150 }
00151 
00152 
00153 static void TAG(render_triangles)( GLcontext *ctx,
00154                    GLuint start,
00155                    GLuint count,
00156                    GLuint flags )
00157 {
00158    GLuint j;
00159    LOCAL_VARS;
00160    (void) flags;
00161 
00162    INIT(GL_TRIANGLES);
00163    if (NEED_EDGEFLAG_SETUP) {
00164       for (j=start+2; j<count; j+=3) {
00165      /* Leave the edgeflags as supplied by the user.
00166       */
00167      RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j) );
00168      RESET_STIPPLE;
00169       }
00170    } else {
00171       for (j=start+2; j<count; j+=3) {
00172      RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j) );
00173       }
00174    }
00175    POSTFIX;
00176 }
00177 
00178 
00179 
00180 static void TAG(render_tri_strip)( GLcontext *ctx,
00181                    GLuint start,
00182                    GLuint count,
00183                    GLuint flags )
00184 {
00185    GLuint j;
00186    GLuint parity = 0;
00187    LOCAL_VARS;
00188 
00189    INIT(GL_TRIANGLE_STRIP);
00190    if (NEED_EDGEFLAG_SETUP) {
00191       for (j=start+2;j<count;j++,parity^=1) {
00192      GLuint ej2 = ELT(j-2+parity);
00193      GLuint ej1 = ELT(j-1-parity);
00194      GLuint ej = ELT(j);
00195      GLboolean ef2 = EDGEFLAG_GET( ej2 );
00196      GLboolean ef1 = EDGEFLAG_GET( ej1 );
00197      GLboolean ef = EDGEFLAG_GET( ej );
00198      EDGEFLAG_SET( ej2, GL_TRUE );
00199      EDGEFLAG_SET( ej1, GL_TRUE );
00200      EDGEFLAG_SET( ej, GL_TRUE );
00201      RENDER_TRI( ej2, ej1, ej );
00202      EDGEFLAG_SET( ej2, ef2 );
00203      EDGEFLAG_SET( ej1, ef1 );
00204      EDGEFLAG_SET( ej, ef );
00205      RESET_STIPPLE;
00206       }
00207    } else {
00208       for (j=start+2; j<count ; j++, parity^=1) {
00209      RENDER_TRI( ELT(j-2+parity), ELT(j-1-parity), ELT(j) );
00210       }
00211    }
00212    POSTFIX;
00213 }
00214 
00215 
00216 static void TAG(render_tri_fan)( GLcontext *ctx,
00217                  GLuint start,
00218                  GLuint count,
00219                  GLuint flags )
00220 {
00221    GLuint j;
00222    LOCAL_VARS;
00223    (void) flags;
00224 
00225    INIT(GL_TRIANGLE_FAN);
00226    if (NEED_EDGEFLAG_SETUP) {
00227       for (j=start+2;j<count;j++) {
00228      /* For trifans, all edges are boundary.
00229       */
00230      GLuint ejs = ELT(start);
00231      GLuint ej1 = ELT(j-1);
00232      GLuint ej = ELT(j);
00233      GLboolean efs = EDGEFLAG_GET( ejs );
00234      GLboolean ef1 = EDGEFLAG_GET( ej1 );
00235      GLboolean ef = EDGEFLAG_GET( ej );
00236      EDGEFLAG_SET( ejs, GL_TRUE );
00237      EDGEFLAG_SET( ej1, GL_TRUE );
00238      EDGEFLAG_SET( ej, GL_TRUE );
00239      RENDER_TRI( ejs, ej1, ej);
00240      EDGEFLAG_SET( ejs, efs );
00241      EDGEFLAG_SET( ej1, ef1 );
00242      EDGEFLAG_SET( ej, ef );
00243      RESET_STIPPLE;
00244       }
00245    } else {
00246       for (j=start+2;j<count;j++) {
00247      RENDER_TRI( ELT(start), ELT(j-1), ELT(j) );
00248       }
00249    }
00250 
00251    POSTFIX;
00252 }
00253 
00254 
00255 static void TAG(render_poly)( GLcontext *ctx,
00256                   GLuint start,
00257                   GLuint count,
00258                   GLuint flags )
00259 {
00260    GLuint j = start+2;
00261    LOCAL_VARS;
00262    (void) flags;
00263 
00264    INIT(GL_POLYGON);
00265    if (NEED_EDGEFLAG_SETUP) {
00266       GLboolean efstart = EDGEFLAG_GET( ELT(start) );
00267       GLboolean efcount = EDGEFLAG_GET( ELT(count-1) );
00268 
00269       /* If the primitive does not begin here, the first edge
00270        * is non-boundary.
00271        */
00272       if (!TEST_PRIM_BEGIN(flags))
00273      EDGEFLAG_SET( ELT(start), GL_FALSE );
00274 
00275       /* If the primitive does not end here, the final edge is
00276        * non-boundary.
00277        */
00278       if (!TEST_PRIM_END(flags))
00279      EDGEFLAG_SET( ELT(count-1), GL_FALSE );
00280 
00281       /* Draw the first triangles (possibly zero)
00282        */
00283       if (j<count-1) {
00284      GLboolean ef = EDGEFLAG_GET( ELT(j) );
00285      EDGEFLAG_SET( ELT(j), GL_FALSE );
00286      RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
00287      EDGEFLAG_SET( ELT(j), ef );
00288      j++;
00289 
00290      /* Don't render the first edge again:
00291       */
00292      EDGEFLAG_SET( ELT(start), GL_FALSE );
00293 
00294      for (;j<count-1;j++) {
00295         GLboolean efj = EDGEFLAG_GET( ELT(j) );
00296         EDGEFLAG_SET( ELT(j), GL_FALSE );
00297         RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
00298         EDGEFLAG_SET( ELT(j), efj );
00299      }
00300       }
00301 
00302       /* Draw the last or only triangle
00303        */
00304       if (j < count)
00305      RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
00306 
00307       /* Restore the first and last edgeflags:
00308        */
00309       EDGEFLAG_SET( ELT(count-1), efcount );
00310       EDGEFLAG_SET( ELT(start), efstart );
00311 
00312       if (TEST_PRIM_END(flags)) {
00313      RESET_STIPPLE;
00314       }
00315    }
00316    else {
00317       for (j=start+2;j<count;j++) {
00318      RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
00319       }
00320    }
00321    POSTFIX;
00322 }
00323 
00324 static void TAG(render_quads)( GLcontext *ctx,
00325                    GLuint start,
00326                    GLuint count,
00327                    GLuint flags )
00328 {
00329    GLuint j;
00330    LOCAL_VARS;
00331    (void) flags;
00332 
00333    INIT(GL_QUADS);
00334    if (NEED_EDGEFLAG_SETUP) {
00335       for (j=start+3; j<count; j+=4) {
00336      /* Use user-specified edgeflags for quads.
00337       */
00338      RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j) );
00339      RESET_STIPPLE;
00340       }
00341    } else {
00342       for (j=start+3; j<count; j+=4) {
00343      RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j) );
00344       }
00345    }
00346    POSTFIX;
00347 }
00348 
00349 static void TAG(render_quad_strip)( GLcontext *ctx,
00350                     GLuint start,
00351                     GLuint count,
00352                     GLuint flags )
00353 {
00354    GLuint j;
00355    LOCAL_VARS;
00356    (void) flags;
00357 
00358    INIT(GL_QUAD_STRIP);
00359    if (NEED_EDGEFLAG_SETUP) {
00360       for (j=start+3;j<count;j+=2) {
00361      /* All edges are boundary.  Set edgeflags to 1, draw the
00362       * quad, and restore them to the original values.
00363       */
00364      GLboolean ef3 = EDGEFLAG_GET( ELT(j-3) );
00365      GLboolean ef2 = EDGEFLAG_GET( ELT(j-2) );
00366      GLboolean ef1 = EDGEFLAG_GET( ELT(j-1) );
00367      GLboolean ef = EDGEFLAG_GET( ELT(j) );
00368      EDGEFLAG_SET( ELT(j-3), GL_TRUE );
00369      EDGEFLAG_SET( ELT(j-2), GL_TRUE );
00370      EDGEFLAG_SET( ELT(j-1), GL_TRUE );
00371      EDGEFLAG_SET( ELT(j), GL_TRUE );
00372      RENDER_QUAD( ELT(j-1), ELT(j-3), ELT(j-2), ELT(j) );
00373      EDGEFLAG_SET( ELT(j-3), ef3 );
00374      EDGEFLAG_SET( ELT(j-2), ef2 );
00375      EDGEFLAG_SET( ELT(j-1), ef1 );
00376      EDGEFLAG_SET( ELT(j), ef );
00377      RESET_STIPPLE;
00378       }
00379    } else {
00380       for (j=start+3;j<count;j+=2) {
00381      RENDER_QUAD( ELT(j-1), ELT(j-3), ELT(j-2), ELT(j) );
00382       }
00383    }
00384    POSTFIX;
00385 }
00386 
00387 static void TAG(render_noop)( GLcontext *ctx,
00388                   GLuint start,
00389                   GLuint count,
00390                   GLuint flags )
00391 {
00392    (void)(ctx && start && count && flags);
00393 }
00394 
00395 RENDER_TAB_QUALIFIER void (*TAG(render_tab)[GL_POLYGON+2])(GLcontext *,
00396                                GLuint,
00397                                GLuint,
00398                                GLuint) =
00399 {
00400    TAG(render_points),
00401    TAG(render_lines),
00402    TAG(render_line_loop),
00403    TAG(render_line_strip),
00404    TAG(render_triangles),
00405    TAG(render_tri_strip),
00406    TAG(render_tri_fan),
00407    TAG(render_quads),
00408    TAG(render_quad_strip),
00409    TAG(render_poly),
00410    TAG(render_noop),
00411 };
00412 
00413 
00414 
00415 #ifndef PRESERVE_VB_DEFS
00416 #undef RENDER_TRI
00417 #undef RENDER_QUAD
00418 #undef RENDER_LINE
00419 #undef RENDER_POINTS
00420 #undef LOCAL_VARS
00421 #undef INIT
00422 #undef POSTFIX
00423 #undef RESET_STIPPLE
00424 #undef DBG
00425 #undef ELT
00426 #undef RENDER_TAB_QUALIFIER
00427 #endif
00428 
00429 #ifndef PRESERVE_TAG
00430 #undef TAG
00431 #endif
00432 
00433 #undef PRESERVE_VB_DEFS
00434 #undef PRESERVE_TAG

Generated on Fri May 25 2012 04:18:56 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.