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

📄 tdfx_state.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 3 页
字号:
      }      fxMesa->dirty |= TDFX_UPLOAD_DITHER;      break;   case GL_FOG:      FLUSH_BATCH( fxMesa );      fxMesa->new_state |= TDFX_NEW_FOG;      break;   case GL_COLOR_LOGIC_OP:      FALLBACK( fxMesa, TDFX_FALLBACK_LOGICOP,		(ctx->Color.ColorLogicOpEnabled &&		 ctx->Color.LogicOp != GL_COPY));      break;   case GL_LIGHTING:      FALLBACK( fxMesa, TDFX_FALLBACK_SPECULAR,		(ctx->Light.Enabled &&		 ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR ));      break;   case GL_LINE_SMOOTH:      FLUSH_BATCH( fxMesa );      fxMesa->new_state |= TDFX_NEW_LINE;      break;   case GL_LINE_STIPPLE:      FALLBACK(fxMesa, TDFX_FALLBACK_LINE_STIPPLE, state);      break;   case GL_POLYGON_STIPPLE:      FLUSH_BATCH(fxMesa);      fxMesa->new_state |= TDFX_NEW_STIPPLE;      break;   case GL_SCISSOR_TEST:      FLUSH_BATCH( fxMesa );      fxMesa->new_state |= TDFX_NEW_CLIP;      break;   case GL_STENCIL_TEST:      FLUSH_BATCH( fxMesa );      FALLBACK( fxMesa, TDFX_FALLBACK_STENCIL, state && !fxMesa->haveHwStencil);      fxMesa->new_state |= TDFX_NEW_STENCIL;      break;   case GL_TEXTURE_3D:      FLUSH_BATCH( fxMesa );      FALLBACK( fxMesa, TDFX_FALLBACK_TEXTURE_MAP, state); /* wrong */      fxMesa->new_state |= TDFX_NEW_TEXTURE;      break;   case GL_TEXTURE_1D:   case GL_TEXTURE_2D:      FLUSH_BATCH( fxMesa );      fxMesa->new_state |= TDFX_NEW_TEXTURE;      break;   default:      return;   }}/* Set the buffer used for drawing *//* XXX support for separate read/draw buffers hasn't been tested */static void tdfxDDDrawBuffer( GLcontext *ctx, GLenum mode ){   tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);   if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {      fprintf( stderr, "%s()\n", __FUNCTION__ );   }   FLUSH_BATCH( fxMesa );   if (ctx->DrawBuffer->_NumColorDrawBuffers > 1) {      FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_TRUE );      return;   }   switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) {   case BUFFER_FRONT_LEFT:      fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_FRONTBUFFER;      fxMesa->new_state |= TDFX_NEW_RENDER;      FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE );      break;   case BUFFER_BACK_LEFT:      fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_BACKBUFFER;      fxMesa->new_state |= TDFX_NEW_RENDER;      FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE );      break;   case -1:      FX_grColorMaskv( ctx, false4 );      FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE );      break;   default:      FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_TRUE );      break;   }}static void tdfxDDReadBuffer( GLcontext *ctx, GLenum mode ){   /* XXX ??? */}/* ============================================================= * Polygon stipple */static void tdfxDDPolygonStipple( GLcontext *ctx, const GLubyte *mask ){   tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);   const GLubyte *m = mask;   GLubyte q[4];   int i,j,k;   GLboolean allBitsSet;/*     int active = (ctx->Polygon.StippleFlag &&  *//*  		 fxMesa->reduced_prim == GL_TRIANGLES); */   FLUSH_BATCH(fxMesa);   fxMesa->Stipple.Pattern = 0xffffffff;   fxMesa->dirty |= TDFX_UPLOAD_STIPPLE;   fxMesa->new_state |= TDFX_NEW_STIPPLE;   /* Check if the stipple pattern is fully opaque.  If so, use software    * rendering.  This basically a trick to make sure the OpenGL conformance    * test passes.    */   allBitsSet = GL_TRUE;   for (i = 0; i < 32; i++) {      if (((GLuint *) mask)[i] != 0xffffffff) {         allBitsSet = GL_FALSE;         break;      }   }   if (allBitsSet) {      fxMesa->haveHwStipple = GL_FALSE;      return;   }   q[0] = mask[0];   q[1] = mask[4];   q[2] = mask[8];   q[3] = mask[12];   for (k = 0 ; k < 8 ; k++)      for (j = 0 ; j < 4; j++)	 for (i = 0 ; i < 4 ; i++,m++) {	    if (*m != q[j]) {	       fxMesa->haveHwStipple = GL_FALSE;	       return;	    }         }   fxMesa->haveHwStipple = GL_TRUE;   fxMesa->Stipple.Pattern = ( (q[0] << 0) |                               (q[1] << 8) |                               (q[2] << 16) |                               (q[3] << 24) );}static void tdfxDDRenderMode( GLcontext *ctx, GLenum mode ){   tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);   FALLBACK( fxMesa, TDFX_FALLBACK_RENDER_MODE, (mode != GL_RENDER) );}static void tdfxDDPrintState( const char *msg, GLuint flags ){   fprintf( stderr,	    "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s\n",	    msg,	    flags,	    (flags & TDFX_NEW_COLOR) ? "color, " : "",	    (flags & TDFX_NEW_ALPHA) ? "alpha, " : "",	    (flags & TDFX_NEW_DEPTH) ? "depth, " : "",	    (flags & TDFX_NEW_RENDER) ? "render, " : "",	    (flags & TDFX_NEW_FOG) ? "fog, " : "",	    (flags & TDFX_NEW_STENCIL) ? "stencil, " : "",	    (flags & TDFX_NEW_STIPPLE) ? "stipple, " : "",	    (flags & TDFX_NEW_CLIP) ? "clip, " : "",	    (flags & TDFX_NEW_VIEWPORT) ? "viewport, " : "",	    (flags & TDFX_NEW_CULL) ? "cull, " : "",	    (flags & TDFX_NEW_GLIDE) ? "glide, " : "",	    (flags & TDFX_NEW_TEXTURE) ? "texture, " : "",	    (flags & TDFX_NEW_CONTEXT) ? "context, " : "");}void tdfxDDUpdateHwState( GLcontext *ctx ){   tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);   int new_state = fxMesa->new_state;   if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {      fprintf( stderr, "%s()\n", __FUNCTION__ );   }   if ( new_state )   {      FLUSH_BATCH( fxMesa );      fxMesa->new_state = 0;      if ( 0 )	 tdfxDDPrintState( "tdfxUpdateHwState", new_state );      /* Update the various parts of the context's state.       */      if ( new_state & TDFX_NEW_ALPHA ) {	 tdfxUpdateAlphaMode( ctx );      }      if ( new_state & TDFX_NEW_DEPTH )	 tdfxUpdateZMode( ctx );      if ( new_state & TDFX_NEW_FOG )	 tdfxUpdateFogAttrib( ctx );      if ( new_state & TDFX_NEW_CLIP )	 tdfxUpdateClipping( ctx );      if ( new_state & TDFX_NEW_STIPPLE )	 tdfxUpdateStipple( ctx );      if ( new_state & TDFX_NEW_CULL )	 tdfxUpdateCull( ctx );      if ( new_state & TDFX_NEW_LINE )         tdfxUpdateLine( ctx );      if ( new_state & TDFX_NEW_VIEWPORT )	 tdfxUpdateViewport( ctx );      if ( new_state & TDFX_NEW_RENDER )	 tdfxUpdateRenderAttrib( ctx );      if ( new_state & TDFX_NEW_STENCIL )         tdfxUpdateStencil( ctx );      if ( new_state & TDFX_NEW_TEXTURE ) {	 tdfxUpdateTextureState( ctx );      }      else if ( new_state & TDFX_NEW_TEXTURE_BIND ) {	 tdfxUpdateTextureBinding( ctx );      }   }   if ( 0 ) {      FxI32 bias = (FxI32) (ctx->Polygon.OffsetUnits * TDFX_DEPTH_BIAS_SCALE);      if ( fxMesa->Depth.Bias != bias ) {	 fxMesa->Depth.Bias = bias;	 fxMesa->dirty |= TDFX_UPLOAD_DEPTH_BIAS;      }   }   if ( fxMesa->dirty ) {      LOCK_HARDWARE( fxMesa );      tdfxEmitHwStateLocked( fxMesa );      UNLOCK_HARDWARE( fxMesa );   }}static void tdfxDDInvalidateState( GLcontext *ctx, GLuint new_state ){   _swrast_InvalidateState( ctx, new_state );   _swsetup_InvalidateState( ctx, new_state );   _vbo_InvalidateState( ctx, new_state );   _tnl_InvalidateState( ctx, new_state );   TDFX_CONTEXT(ctx)->new_gl_state |= new_state;}/* Initialize the context's Glide state mirror.  These values will be * used as Glide function call parameters when the time comes. */void tdfxInitState( tdfxContextPtr fxMesa ){   GLcontext *ctx = fxMesa->glCtx;   GLint i;   fxMesa->ColorCombine.Function	= GR_COMBINE_FUNCTION_LOCAL;   fxMesa->ColorCombine.Factor		= GR_COMBINE_FACTOR_NONE;   fxMesa->ColorCombine.Local		= GR_COMBINE_LOCAL_ITERATED;   fxMesa->ColorCombine.Other		= GR_COMBINE_OTHER_NONE;   fxMesa->ColorCombine.Invert		= FXFALSE;   fxMesa->AlphaCombine.Function	= GR_COMBINE_FUNCTION_LOCAL;   fxMesa->AlphaCombine.Factor		= GR_COMBINE_FACTOR_NONE;   fxMesa->AlphaCombine.Local		= GR_COMBINE_LOCAL_ITERATED;   fxMesa->AlphaCombine.Other		= GR_COMBINE_OTHER_NONE;   fxMesa->AlphaCombine.Invert		= FXFALSE;   fxMesa->ColorCombineExt.SourceA	= GR_CMBX_ITRGB;   fxMesa->ColorCombineExt.ModeA	= GR_FUNC_MODE_X;   fxMesa->ColorCombineExt.SourceB	= GR_CMBX_ZERO;   fxMesa->ColorCombineExt.ModeB	= GR_FUNC_MODE_ZERO;   fxMesa->ColorCombineExt.SourceC	= GR_CMBX_ZERO;   fxMesa->ColorCombineExt.InvertC	= FXTRUE;   fxMesa->ColorCombineExt.SourceD	= GR_CMBX_ZERO;   fxMesa->ColorCombineExt.InvertD	= FXFALSE;   fxMesa->ColorCombineExt.Shift	= 0;   fxMesa->ColorCombineExt.Invert	= FXFALSE;   fxMesa->AlphaCombineExt.SourceA	= GR_CMBX_ITALPHA;   fxMesa->AlphaCombineExt.ModeA	= GR_FUNC_MODE_X;   fxMesa->AlphaCombineExt.SourceB	= GR_CMBX_ZERO;   fxMesa->AlphaCombineExt.ModeB	= GR_FUNC_MODE_ZERO;   fxMesa->AlphaCombineExt.SourceC	= GR_CMBX_ZERO;   fxMesa->AlphaCombineExt.InvertC	= FXTRUE;   fxMesa->AlphaCombineExt.SourceD	= GR_CMBX_ZERO;   fxMesa->AlphaCombineExt.InvertD	= FXFALSE;   fxMesa->AlphaCombineExt.Shift	= 0;   fxMesa->AlphaCombineExt.Invert	= FXFALSE;   fxMesa->sScale0 = fxMesa->tScale0 = 1.0;   fxMesa->sScale1 = fxMesa->tScale1 = 1.0;   fxMesa->TexPalette.Type = 0;   fxMesa->TexPalette.Data = NULL;   for ( i = 0 ; i < TDFX_NUM_TMU ; i++ ) {      fxMesa->TexSource[i].StartAddress	= 0;      fxMesa->TexSource[i].EvenOdd	= GR_MIPMAPLEVELMASK_EVEN;      fxMesa->TexSource[i].Info		= NULL;      fxMesa->TexCombine[i].FunctionRGB		= 0;      fxMesa->TexCombine[i].FactorRGB		= 0;      fxMesa->TexCombine[i].FunctionAlpha	= 0;      fxMesa->TexCombine[i].FactorAlpha		= 0;      fxMesa->TexCombine[i].InvertRGB		= FXFALSE;      fxMesa->TexCombine[i].InvertAlpha		= FXFALSE;      fxMesa->TexCombineExt[i].Alpha.SourceA	= 0;      /* XXX more state to init here */      fxMesa->TexCombineExt[i].Color.SourceA	= 0;      fxMesa->TexCombineExt[i].EnvColor        = 0x0;      fxMesa->TexParams[i].sClamp 	= GR_TEXTURECLAMP_WRAP;      fxMesa->TexParams[i].tClamp	= GR_TEXTURECLAMP_WRAP;      fxMesa->TexParams[i].minFilt	= GR_TEXTUREFILTER_POINT_SAMPLED;      fxMesa->TexParams[i].magFilt	= GR_TEXTUREFILTER_BILINEAR;      fxMesa->TexParams[i].mmMode	= GR_MIPMAP_DISABLE;      fxMesa->TexParams[i].LODblend	= FXFALSE;      fxMesa->TexParams[i].LodBias	= 0.0;      fxMesa->TexState.EnvMode[i]	= ~0;      fxMesa->TexState.TexFormat[i]	= ~0;      fxMesa->TexState.Enabled[i]	= 0;   }   if ( ctx->Visual.doubleBufferMode) {      fxMesa->DrawBuffer		= GR_BUFFER_BACKBUFFER;      fxMesa->ReadBuffer		= GR_BUFFER_BACKBUFFER;   } else {      fxMesa->DrawBuffer		= GR_BUFFER_FRONTBUFFER;      fxMesa->ReadBuffer		= GR_BUFFER_FRONTBUFFER;   }   fxMesa->Color.ClearColor		= 0x00000000;   fxMesa->Color.ClearAlpha		= 0x00;   fxMesa->Color.ColorMask[RCOMP]	= FXTRUE;   fxMesa->Color.ColorMask[BCOMP]	= FXTRUE;   fxMesa->Color.ColorMask[GCOMP]	= FXTRUE;   fxMesa->Color.ColorMask[ACOMP]	= FXTRUE;   fxMesa->Color.MonoColor		= 0xffffffff;   fxMesa->Color.AlphaFunc		= GR_CMP_ALWAYS;   fxMesa->Color.AlphaRef		= 0x00;   fxMesa->Color.BlendSrcRGB		= GR_BLEND_ONE;   fxMesa->Color.BlendDstRGB		= GR_BLEND_ZERO;   fxMesa->Color.BlendSrcA		= GR_BLEND_ONE;   fxMesa->Color.BlendSrcA		= GR_BLEND_ZERO;   fxMesa->Color.Dither			= GR_DITHER_2x2;   if ( fxMesa->glCtx->Visual.depthBits > 0 ) {      fxMesa->Depth.Mode		= GR_DEPTHBUFFER_ZBUFFER;   } else {      fxMesa->Depth.Mode		= GR_DEPTHBUFFER_DISABLE;   }   fxMesa->Depth.Bias			= 0;   fxMesa->Depth.Func			= GR_CMP_LESS;   fxMesa->Depth.Clear			= 0; /* computed later */   fxMesa->Depth.Mask			= FXTRUE;   fxMesa->Fog.Mode			= GR_FOG_DISABLE;   fxMesa->Fog.Color			= 0x00000000;   fxMesa->Fog.Table			= NULL;   fxMesa->Fog.Density			= 1.0;   fxMesa->Fog.Near			= 1.0;   fxMesa->Fog.Far			= 1.0;   fxMesa->Stencil.Function		= GR_CMP_ALWAYS;   fxMesa->Stencil.RefValue		= 0;   fxMesa->Stencil.ValueMask		= 0xff;   fxMesa->Stencil.WriteMask		= 0xff;   fxMesa->Stencil.FailFunc		= 0;   fxMesa->Stencil.ZFailFunc		= 0;   fxMesa->Stencil.ZPassFunc		= 0;   fxMesa->Stencil.Clear		= 0;   fxMesa->Stipple.Mode                 = GR_STIPPLE_DISABLE;   fxMesa->Stipple.Pattern              = 0xffffffff;   fxMesa->Scissor.minX			= 0;   fxMesa->Scissor.minY			= 0;   fxMesa->Scissor.maxX			= 0;   fxMesa->Scissor.maxY			= 0;   fxMesa->Viewport.Mode		= GR_WINDOW_COORDS;   fxMesa->Viewport.X			= 0;   fxMesa->Viewport.Y			= 0;   fxMesa->Viewport.Width		= 0;   fxMesa->Viewport.Height		= 0;   fxMesa->Viewport.Near		= 0.0;   fxMesa->Viewport.Far			= 0.0;   fxMesa->CullMode			= GR_CULL_DISABLE;   fxMesa->Glide.ColorFormat		= GR_COLORFORMAT_ABGR;   fxMesa->Glide.Origin			= GR_ORIGIN_LOWER_LEFT;   fxMesa->Glide.Initialized		= FXFALSE;}void tdfxDDInitStateFuncs( GLcontext *ctx ){   tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);   ctx->Driver.UpdateState		= tdfxDDInvalidateState;   ctx->Driver.ClearColor		= tdfxDDClearColor;   ctx->Driver.DrawBuffer		= tdfxDDDrawBuffer;   ctx->Driver.ReadBuffer		= tdfxDDReadBuffer;   ctx->Driver.AlphaFunc		= tdfxDDAlphaFunc;   ctx->Driver.BlendEquationSeparate	= tdfxDDBlendEquationSeparate;   ctx->Driver.BlendFuncSeparate	= tdfxDDBlendFuncSeparate;   ctx->Driver.ClearDepth		= tdfxDDClearDepth;   ctx->Driver.ColorMask		= tdfxDDColorMask;   ctx->Driver.CullFace			= tdfxDDCullFace;   ctx->Driver.FrontFace		= tdfxDDFrontFace;   ctx->Driver.DepthFunc		= tdfxDDDepthFunc;   ctx->Driver.DepthMask		= tdfxDDDepthMask;   ctx->Driver.DepthRange		= tdfxDDDepthRange;   ctx->Driver.Enable			= tdfxDDEnable;   ctx->Driver.Fogfv			= tdfxDDFogfv;   ctx->Driver.LightModelfv		= tdfxDDLightModelfv;   ctx->Driver.LineWidth		= tdfxDDLineWidth;   ctx->Driver.PolygonStipple		= tdfxDDPolygonStipple;   ctx->Driver.RenderMode               = tdfxDDRenderMode;   ctx->Driver.Scissor			= tdfxDDScissor;   ctx->Driver.ShadeModel		= tdfxDDShadeModel;   if ( fxMesa->haveHwStencil ) {      ctx->Driver.StencilFuncSeparate	= tdfxDDStencilFuncSeparate;      ctx->Driver.StencilMaskSeparate	= tdfxDDStencilMaskSeparate;      ctx->Driver.StencilOpSeparate	= tdfxDDStencilOpSeparate;   }   ctx->Driver.Viewport			= tdfxDDViewport;}

⌨️ 快捷键说明

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