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_imm_vb.c
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_whitwell@yahoo.com>
00027  */
00028 
00029 /* Template to build clipping routines to support t_dd_imm_primtmp.h.
00030  *
00031  * The TAG(draw_line) and TAG(draw_triangle) routines are called in
00032  * clipping and fallback scenarios, and when the native hardware
00033  * primitive (eg polygons) is unavailable.
00034  */
00035 
00036 
00037 #define CLIP_DOTPROD(K, A, B, C, D)     \
00038    (CLIP_X(K)*A + CLIP_Y(K)*B +     \
00039     CLIP_Z(K)*C + CLIP_W(K)*D)
00040 
00041 #define POLY_CLIP( PLANE, A, B, C, D )                  \
00042 do {                                    \
00043    if (mask & PLANE) {                          \
00044       TNL_VERTEX **indata = inlist[in];                 \
00045       TNL_VERTEX **outdata = inlist[in ^= 1];               \
00046       TNL_VERTEX *J = indata[0];                    \
00047       GLfloat dpJ = CLIP_DOTPROD(J, A, B, C, D );           \
00048       GLuint outcount = 0;                      \
00049       GLuint i;                             \
00050                                     \
00051       indata[n] = indata[0]; /* prevent rotation of vertices */     \
00052       for (i = 1; i <= n; i++) {                    \
00053      TNL_VERTEX *I = indata[i];                 \
00054      GLfloat dpI = CLIP_DOTPROD(idx, A, B, C, D );          \
00055                                     \
00056      if (!NEGATIVE(dpPrev)) {                   \
00057         outdata[outcount++] = J;                    \
00058      }                              \
00059                                     \
00060      if (DIFFERENT_SIGNS(dpI, dpJ)) {               \
00061             TNL_VERTEX *O = verts++;                    \
00062             outdata[outcount++] = O;                    \
00063         if (NEGATIVE(dpI)) {                    \
00064            /* Going out of bounds.  Avoid division by zero as we    \
00065         * know dp != dpPrev from DIFFERENT_SIGNS, above.    \
00066         */                          \
00067            GLfloat t = dpI / (dpI - dpJ);               \
00068                INTERP( ctx, t, O, I, J );               \
00069         } else {                            \
00070            /* Coming back in.                   \
00071         */                          \
00072            GLfloat t = dpJ / (dpJ - dpI);               \
00073            INTERP( ctx, t, O, J, I );               \
00074         }                               \
00075      }                              \
00076                                     \
00077      J = I;                             \
00078      dpJ = dpI;                         \
00079       }                                 \
00080                                     \
00081       if (outcount < 3)                         \
00082      return;                            \
00083                                     \
00084       nr = outcount;                            \
00085    }                                    \
00086 } while (0)
00087 
00088 
00089 #define LINE_CLIP(PLANE, A, B, C, D )           \
00090 do {                            \
00091    if (mask & PLANE) {                  \
00092       GLfloat dpI = CLIP_DOTPROD( I, A, B, C, D );  \
00093       GLfloat dpJ = CLIP_DOTPROD( J, A, B, C, D );  \
00094                             \
00095       if (DIFFERENT_SIGNS(dpI, dpJ)) {          \
00096          TNL_VERTEX *O = verts++;           \
00097      if (NEGATIVE(dpJ)) {               \
00098         GLfloat t = dpI / (dpI - dpJ);      \
00099         INTERP( ctx, t, O, I, J );  \
00100             J = O;                  \
00101      } else {                   \
00102         GLfloat t = dpJ / (dpJ - dpI);      \
00103         INTERP( ctx, t, O, J, I );  \
00104             I = O;                  \
00105      }                      \
00106       }                         \
00107       else if (NEGATIVE(dpI))               \
00108      return;                    \
00109   }                         \
00110 } while (0)
00111 
00112 
00113 
00114 /* Clip a line against the viewport and user clip planes.
00115  */
00116 static void TAG(clip_draw_line)( GLcontext *ctx,
00117                  TNL_VERTEX *I,
00118                  TNL_VERTEX *J,
00119                  GLuint mask )
00120 {
00121    LOCAL_VARS;
00122    GET_INTERP_FUNC;
00123    TNL_VERTEX tmp[MAX_CLIPPED_VERTICES];
00124    TNL_VERTEX *verts = tmp;
00125    TNL_VERTEX *pv = J;
00126 
00127    LINE_CLIP( CLIP_RIGHT_BIT,  -1,  0,  0, 1 );
00128    LINE_CLIP( CLIP_LEFT_BIT,    1,  0,  0, 1 );
00129    LINE_CLIP( CLIP_TOP_BIT,     0, -1,  0, 1 );
00130    LINE_CLIP( CLIP_BOTTOM_BIT,  0,  1,  0, 1 );
00131    LINE_CLIP( CLIP_FAR_BIT,     0,  0, -1, 1 );
00132    LINE_CLIP( CLIP_NEAR_BIT,    0,  0,  1, 1 );
00133 
00134    if ((ctx->_TriangleCaps & DD_FLATSHADE) && J != pv)
00135       COPY_PV( ctx, J, pv );
00136 
00137    DRAW_LINE( I, J );
00138 }
00139 
00140 
00141 /* Clip a triangle against the viewport and user clip planes.
00142  */
00143 static void TAG(clip_draw_triangle)( GLcontext *ctx,
00144                      TNL_VERTEX *v0,
00145                      TNL_VERTEX *v1,
00146                      TNL_VERTEX *v2,
00147                      GLuint mask )
00148 {
00149    LOCAL_VARS;
00150    GET_INTERP_FUNC;
00151    TNL_VERTEX tmp[MAX_CLIPPED_VERTICES];
00152    TNL_VERTEX *verts = tmp;
00153    TNL_VERTEX *(inlist[2][MAX_CLIPPED_VERTICES]);
00154    TNL_VERTEX **out;
00155    GLuint in = 0;
00156    GLuint n = 3;
00157    GLuint i;
00158 
00159    ASSIGN_3V(inlist, v2, v0, v1 ); /* pv rotated to slot zero */
00160 
00161    POLY_CLIP( CLIP_RIGHT_BIT,  -1,  0,  0, 1 );
00162    POLY_CLIP( CLIP_LEFT_BIT,    1,  0,  0, 1 );
00163    POLY_CLIP( CLIP_TOP_BIT,     0, -1,  0, 1 );
00164    POLY_CLIP( CLIP_BOTTOM_BIT,  0,  1,  0, 1 );
00165    POLY_CLIP( CLIP_FAR_BIT,     0,  0, -1, 1 );
00166    POLY_CLIP( CLIP_NEAR_BIT,    0,  0,  1, 1 );
00167 
00168    if ((ctx->_TriangleCaps & DD_FLATSHADE) && v2 != inlist[0]) 
00169       COPY_PV( ctx, inlist[0], v2 );
00170 
00171    out = inlist[in];
00172    DRAW_POLYGON( out, n );
00173 }
00174 
00175 
00176 static __inline void TAG(draw_triangle)( GLcontext *ctx,
00177                      TNL_VERTEX *v0,
00178                      TNL_VERTEX *v1,
00179                      TNL_VERTEX *v2 )
00180 {
00181    LOCAL_VARS;
00182    GLubyte ormask = (v0->mask | v1->mask | v2->mask);
00183 
00184    if ( !ormask ) {
00185       DRAW_TRI( v0, v1, v2 );
00186    } else if ( !(v0->mask & v1->mask & v2->mask) ) {
00187       TAG(clip_draw_triangle)( ctx, v0, v1, v2, ormask );
00188    }
00189 }
00190 
00191 static __inline void TAG(draw_line)( GLcontext *ctx,
00192                      TNL_VERTEX *v0,
00193                      TNL_VERTEX *v1 )
00194 {
00195    LOCAL_VARS;
00196    GLubyte ormask = (v0->mask | v1->mask);
00197 
00198    if ( !ormask ) {
00199       DRAW_LINE( v0, v1 );
00200    } else if ( !(v0->mask & v1->mask) ) {
00201       TAG(clip_draw_line)( ctx, v0, v1, ormask );
00202    }
00203 }
00204 

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