⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 t_dd_tritmp.h

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 H
📖 第 1 页 / 共 2 页
字号:
      GLfloat cc = ex*fy - ey*fx;      if (DO_TWOSIDE || DO_UNFILLED || DO_TWOSTENCIL)      {	 facing = AREA_IS_CCW( cc ) ^ ctx->Polygon._FrontBit;	 if (DO_UNFILLED) {	    if (facing) {	       mode = ctx->Polygon.BackMode;	       if (ctx->Polygon.CullFlag &&		   ctx->Polygon.CullFaceMode != GL_FRONT) {		  return;	       }	    } else {	       mode = ctx->Polygon.FrontMode;	       if (ctx->Polygon.CullFlag &&		   ctx->Polygon.CullFaceMode != GL_BACK) {		  return;	       }	    }	 }	 if (DO_TWOSIDE && facing == 1)	 {	    if (HAVE_RGBA) {	       GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data;	       (void)vbcolor;	       if (HAVE_BACK_COLORS) {                  if (!DO_FLAT) {                     VERT_SAVE_RGBA( 0 );                     VERT_SAVE_RGBA( 1 );                     VERT_SAVE_RGBA( 2 );		     VERT_COPY_RGBA1( v[0] );		     VERT_COPY_RGBA1( v[1] );		     VERT_COPY_RGBA1( v[2] );		  }		  VERT_SAVE_RGBA( 3 );		  VERT_COPY_RGBA1( v[3] );		  if (HAVE_SPEC) {                     if (!DO_FLAT) {                        VERT_SAVE_SPEC( 0 );                        VERT_SAVE_SPEC( 1 );                        VERT_SAVE_SPEC( 2 );			VERT_COPY_SPEC1( v[0] );			VERT_COPY_SPEC1( v[1] );			VERT_COPY_SPEC1( v[2] );		     }		     VERT_SAVE_SPEC( 3 );		     VERT_COPY_SPEC1( v[3] );		  }	       }	       else {	          if (!DO_FLAT) {		     VERT_SAVE_RGBA( 0 );		     VERT_SAVE_RGBA( 1 );		     VERT_SAVE_RGBA( 2 );		  }	          VERT_SAVE_RGBA( 3 );		  if (VB->ColorPtr[1]->stride) {		     if (!DO_FLAT) {			VERT_SET_RGBA( v[0], vbcolor[e0] );			VERT_SET_RGBA( v[1], vbcolor[e1] );			VERT_SET_RGBA( v[2], vbcolor[e2] );		     }		     VERT_SET_RGBA( v[3], vbcolor[e3] );		  }		  else {		     if (!DO_FLAT) {			VERT_SET_RGBA( v[0], vbcolor[0] );			VERT_SET_RGBA( v[1], vbcolor[0] );			VERT_SET_RGBA( v[2], vbcolor[0] );		     }		     VERT_SET_RGBA( v[3], vbcolor[0] );		  }	          if (HAVE_SPEC && VB->SecondaryColorPtr[1]) {		     GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data;		     ASSERT(VB->SecondaryColorPtr[1]->stride==4*sizeof(GLfloat));		     if (!DO_FLAT) {		        VERT_SAVE_SPEC( 0 );		        VERT_SAVE_SPEC( 1 );		        VERT_SAVE_SPEC( 2 );		        VERT_SET_SPEC( v[0], vbspec[e0] );		        VERT_SET_SPEC( v[1], vbspec[e1] );		        VERT_SET_SPEC( v[2], vbspec[e2] );		     }		     VERT_SAVE_SPEC( 3 );		     VERT_SET_SPEC( v[3], vbspec[e3] );	          }	       }	    }	    else {	       GLfloat *vbindex = (GLfloat *)VB->IndexPtr[1]->data;	       if (!DO_FLAT) {		  VERT_SAVE_IND( 0 );		  VERT_SAVE_IND( 1 );		  VERT_SAVE_IND( 2 );		  VERT_SET_IND( v[0], vbindex[e0] );		  VERT_SET_IND( v[1], vbindex[e1] );		  VERT_SET_IND( v[2], vbindex[e2] );	       }	       VERT_SAVE_IND( 3 );	       VERT_SET_IND( v[3], vbindex[e3] );	    }	 }      }      if (DO_OFFSET)      {	 offset = ctx->Polygon.OffsetUnits * DEPTH_SCALE;	 z[0] = VERT_Z(v[0]);	 z[1] = VERT_Z(v[1]);	 z[2] = VERT_Z(v[2]);	 z[3] = VERT_Z(v[3]);	 if (cc * cc > 1e-16) {	    GLfloat ez = z[2] - z[0];	    GLfloat fz = z[3] - z[1];	    GLfloat a	= ey*fz - ez*fy;	    GLfloat b	= ez*fx - ex*fz;	    GLfloat ic	= 1.0 / cc;	    GLfloat ac	= a * ic;	    GLfloat bc	= b * ic;	    if ( ac < 0.0f ) ac = -ac;	    if ( bc < 0.0f ) bc = -bc;	    offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor / ctx->DrawBuffer->_MRD;	 }	 offset *= ctx->DrawBuffer->_MRD * (REVERSE_DEPTH ? -1.0 : 1.0);      }   }   if (DO_FLAT) {      if (HAVE_RGBA) {	 VERT_SAVE_RGBA( 0 );	 VERT_SAVE_RGBA( 1 );	 VERT_SAVE_RGBA( 2 );	 VERT_COPY_RGBA( v[0], v[3] );	 VERT_COPY_RGBA( v[1], v[3] );	 VERT_COPY_RGBA( v[2], v[3] );	 if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {	    VERT_SAVE_SPEC( 0 );	    VERT_SAVE_SPEC( 1 );	    VERT_SAVE_SPEC( 2 );	    VERT_COPY_SPEC( v[0], v[3] );	    VERT_COPY_SPEC( v[1], v[3] );	    VERT_COPY_SPEC( v[2], v[3] );	 }      }      else {	 VERT_SAVE_IND( 0 );	 VERT_SAVE_IND( 1 );	 VERT_SAVE_IND( 2 );	 VERT_COPY_IND( v[0], v[3] );	 VERT_COPY_IND( v[1], v[3] );	 VERT_COPY_IND( v[2], v[3] );      }   }   if (mode == GL_POINT) {      if (( DO_OFFSET) && ctx->Polygon.OffsetPoint) {	 VERT_Z_ADD(v[0], offset);	 VERT_Z_ADD(v[1], offset);	 VERT_Z_ADD(v[2], offset);	 VERT_Z_ADD(v[3], offset);      }      if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide) {         SETUP_STENCIL(facing);         UNFILLED_QUAD( ctx, GL_POINT, e0, e1, e2, e3 );         UNSET_STENCIL(facing);      } else {         UNFILLED_QUAD( ctx, GL_POINT, e0, e1, e2, e3 );      }   } else if (mode == GL_LINE) {      if (DO_OFFSET && ctx->Polygon.OffsetLine) {	 VERT_Z_ADD(v[0], offset);	 VERT_Z_ADD(v[1], offset);	 VERT_Z_ADD(v[2], offset);	 VERT_Z_ADD(v[3], offset);      }      if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide) {         SETUP_STENCIL(facing);         UNFILLED_QUAD( ctx, GL_LINE, e0, e1, e2, e3 );         UNSET_STENCIL(facing);      } else {         UNFILLED_QUAD( ctx, GL_LINE, e0, e1, e2, e3 );      }   } else {      if (DO_OFFSET && ctx->Polygon.OffsetFill) {	 VERT_Z_ADD(v[0], offset);	 VERT_Z_ADD(v[1], offset);	 VERT_Z_ADD(v[2], offset);	 VERT_Z_ADD(v[3], offset);      }      RASTERIZE( GL_QUADS );      if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide) {         SETUP_STENCIL(facing);         QUAD( (v[0]), (v[1]), (v[2]), (v[3]) );         UNSET_STENCIL(facing);      } else {         QUAD( (v[0]), (v[1]), (v[2]), (v[3]) );      }   }   if (DO_OFFSET)   {      VERT_SET_Z(v[0], z[0]);      VERT_SET_Z(v[1], z[1]);      VERT_SET_Z(v[2], z[2]);      VERT_SET_Z(v[3], z[3]);   }   if (DO_TWOSIDE && facing == 1)   {      if (HAVE_RGBA) {	 if (!DO_FLAT) {	    VERT_RESTORE_RGBA( 0 );	    VERT_RESTORE_RGBA( 1 );	    VERT_RESTORE_RGBA( 2 );	 }	 VERT_RESTORE_RGBA( 3 );	 if (HAVE_SPEC) {	    if (!DO_FLAT) {	       VERT_RESTORE_SPEC( 0 );	       VERT_RESTORE_SPEC( 1 );	       VERT_RESTORE_SPEC( 2 );	    }	    VERT_RESTORE_SPEC( 3 );	 }      }      else {	 if (!DO_FLAT) {	    VERT_RESTORE_IND( 0 );	    VERT_RESTORE_IND( 1 );	    VERT_RESTORE_IND( 2 );	 }	 VERT_RESTORE_IND( 3 );      }   }   if (DO_FLAT) {      if (HAVE_RGBA) {	 VERT_RESTORE_RGBA( 0 );	 VERT_RESTORE_RGBA( 1 );	 VERT_RESTORE_RGBA( 2 );	 if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {	    VERT_RESTORE_SPEC( 0 );	    VERT_RESTORE_SPEC( 1 );	    VERT_RESTORE_SPEC( 2 );	 }      }      else {	 VERT_RESTORE_IND( 0 );	 VERT_RESTORE_IND( 1 );	 VERT_RESTORE_IND( 2 );      }   }}#elsestatic void TAG(quadr)( GLcontext *ctx, GLuint e0,		       GLuint e1, GLuint e2, GLuint e3 ){   if (DO_UNFILLED) {      struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;      GLubyte ef1 = VB->EdgeFlag[e1];      GLubyte ef3 = VB->EdgeFlag[e3];      VB->EdgeFlag[e1] = 0;      TAG(triangle)( ctx, e0, e1, e3 );      VB->EdgeFlag[e1] = ef1;      VB->EdgeFlag[e3] = 0;      TAG(triangle)( ctx, e1, e2, e3 );      VB->EdgeFlag[e3] = ef3;   } else {      TAG(triangle)( ctx, e0, e1, e3 );      TAG(triangle)( ctx, e1, e2, e3 );   }}#endif#endif#if DO_LINEstatic void TAG(line)( GLcontext *ctx, GLuint e0, GLuint e1 ){   struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;   VERTEX *v[2];   LOCAL_VARS(2);   v[0] = (VERTEX *)GET_VERTEX(e0);   v[1] = (VERTEX *)GET_VERTEX(e1);   if (DO_FLAT) {      if (HAVE_RGBA) {	 VERT_SAVE_RGBA( 0 );	 VERT_COPY_RGBA( v[0], v[1] );	 if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {	    VERT_SAVE_SPEC( 0 );	    VERT_COPY_SPEC( v[0], v[1] );	 }      }      else {	 VERT_SAVE_IND( 0 );	 VERT_COPY_IND( v[0], v[1] );      }   }   LINE( v[0], v[1] );   if (DO_FLAT) {      if (HAVE_RGBA) {	 VERT_RESTORE_RGBA( 0 );	 if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {	    VERT_RESTORE_SPEC( 0 );	 }      }      else {	 VERT_RESTORE_IND( 0 );      }   }}#endif#if DO_POINTSstatic void TAG(points)( GLcontext *ctx, GLuint first, GLuint last ){   struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;   GLuint i;   LOCAL_VARS(1);   if (VB->Elts == 0) {      for ( i = first ; i < last ; i++ ) {	 if ( VB->ClipMask[i] == 0 ) {	    VERTEX *v = (VERTEX *)GET_VERTEX(i);	    POINT( v );	 }      }   } else {      for ( i = first ; i < last ; i++ ) {	 GLuint e = VB->Elts[i];	 if ( VB->ClipMask[e] == 0 ) {	    VERTEX *v = (VERTEX *)GET_VERTEX(e);	    POINT( v );	 }      }   }}#endifstatic void TAG(init)( void ){#if DO_QUAD   TAB[IND].quad = TAG(quadr);#endif#if DO_TRI   TAB[IND].triangle = TAG(triangle);#endif#if DO_LINE   TAB[IND].line = TAG(line);#endif#if DO_POINTS   TAB[IND].points = TAG(points);#endif}#undef IND#undef TAG#if HAVE_RGBA#undef VERT_SET_IND#undef VERT_COPY_IND#undef VERT_SAVE_IND#undef VERT_RESTORE_IND#if HAVE_BACK_COLORS#undef VERT_SET_RGBA#endif#else#undef VERT_SET_RGBA#undef VERT_COPY_RGBA#undef VERT_SAVE_RGBA#undef VERT_RESTORE_RGBA#if HAVE_BACK_COLORS#undef VERT_SET_IND#endif#endif#if !HAVE_SPEC#undef VERT_SET_SPEC#undef VERT_COPY_SPEC#undef VERT_SAVE_SPEC#undef VERT_RESTORE_SPEC#if HAVE_BACK_COLORS#undef VERT_COPY_SPEC1#endif#else#if HAVE_BACK_COLORS#undef VERT_SET_SPEC#endif#endif#if !HAVE_BACK_COLORS#undef VERT_COPY_SPEC1#undef VERT_COPY_IND1#undef VERT_COPY_RGBA1#endif#ifndef INSANE_VERTICES#undef VERT_SET_Z#undef VERT_Z_ADD#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -