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

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