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

📄 fxsetup.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 5 页
字号:
static GrStencil_t convertGLStencilOp( GLenum op ){   switch ( op ) {   case GL_KEEP:      return GR_STENCILOP_KEEP;   case GL_ZERO:      return GR_STENCILOP_ZERO;   case GL_REPLACE:      return GR_STENCILOP_REPLACE;   case GL_INCR:      return GR_STENCILOP_INCR_CLAMP;   case GL_DECR:      return GR_STENCILOP_DECR_CLAMP;   case GL_INVERT:      return GR_STENCILOP_INVERT;   case GL_INCR_WRAP_EXT:      return GR_STENCILOP_INCR_WRAP;   case GL_DECR_WRAP_EXT:      return GR_STENCILOP_DECR_WRAP;   default:      _mesa_problem( NULL, "bad stencil op in convertGLStencilOp" );   }   return GR_STENCILOP_KEEP;   /* never get, silence compiler warning */}voidfxDDStencilFuncSeparate (GLcontext *ctx, GLenum face, GLenum func,                         GLint ref, GLuint mask){   fxMesaContext fxMesa = FX_CONTEXT(ctx);   tfxUnitsState *us = &fxMesa->unitsState;   if (ctx->Stencil.ActiveFace) {      return;   }   if (       (us->stencilFunction != func)       ||       (us->stencilRefValue != ref)       ||       (us->stencilValueMask != mask)      ) {      us->stencilFunction = func;      us->stencilRefValue = ref;      us->stencilValueMask = mask;      fxMesa->new_state |= FX_NEW_STENCIL;   }}voidfxDDStencilMaskSeparate (GLcontext *ctx, GLenum face, GLuint mask){   fxMesaContext fxMesa = FX_CONTEXT(ctx);   tfxUnitsState *us = &fxMesa->unitsState;   if (ctx->Stencil.ActiveFace) {      return;   }   if (us->stencilWriteMask != mask) {      us->stencilWriteMask = mask;      fxMesa->new_state |= FX_NEW_STENCIL;   }}voidfxDDStencilOpSeparate (GLcontext *ctx, GLenum face, GLenum sfail,                       GLenum zfail, GLenum zpass){   fxMesaContext fxMesa = FX_CONTEXT(ctx);   tfxUnitsState *us = &fxMesa->unitsState;   if (ctx->Stencil.ActiveFace) {      return;   }   if (       (us->stencilFailFunc != sfail)       ||       (us->stencilZFailFunc != zfail)       ||       (us->stencilZPassFunc != zpass)      ) {      us->stencilFailFunc = sfail;      us->stencilZFailFunc = zfail;      us->stencilZPassFunc = zpass;      fxMesa->new_state |= FX_NEW_STENCIL;   }}voidfxSetupStencil (GLcontext * ctx){   fxMesaContext fxMesa = FX_CONTEXT(ctx);   tfxUnitsState *us = &fxMesa->unitsState;   if (us->stencilEnabled) {      GrCmpFnc_t stencilFailFunc = GR_STENCILOP_KEEP;      GrCmpFnc_t stencilZFailFunc = GR_STENCILOP_KEEP;      GrCmpFnc_t stencilZPassFunc = GR_STENCILOP_KEEP;      if (!fxMesa->multipass) {         stencilFailFunc = convertGLStencilOp(us->stencilFailFunc);         stencilZFailFunc = convertGLStencilOp(us->stencilZFailFunc);         stencilZPassFunc = convertGLStencilOp(us->stencilZPassFunc);      }      grEnable(GR_STENCIL_MODE_EXT);      fxMesa->Glide.grStencilOpExt(stencilFailFunc,                                   stencilZFailFunc,                                   stencilZPassFunc);      fxMesa->Glide.grStencilFuncExt(us->stencilFunction - GL_NEVER + GR_CMP_NEVER,                                     us->stencilRefValue,                                     us->stencilValueMask);      fxMesa->Glide.grStencilMaskExt(us->stencilWriteMask);   } else {      grDisable(GR_STENCIL_MODE_EXT);   }}voidfxSetupStencilFace (GLcontext * ctx, GLint face){   fxMesaContext fxMesa = FX_CONTEXT(ctx);   tfxUnitsState *us = &fxMesa->unitsState;   if (us->stencilEnabled) {      GrCmpFnc_t stencilFailFunc = GR_STENCILOP_KEEP;      GrCmpFnc_t stencilZFailFunc = GR_STENCILOP_KEEP;      GrCmpFnc_t stencilZPassFunc = GR_STENCILOP_KEEP;      if (!fxMesa->multipass) {         stencilFailFunc = convertGLStencilOp(ctx->Stencil.FailFunc[face]);         stencilZFailFunc = convertGLStencilOp(ctx->Stencil.ZFailFunc[face]);         stencilZPassFunc = convertGLStencilOp(ctx->Stencil.ZPassFunc[face]);      }      grEnable(GR_STENCIL_MODE_EXT);      fxMesa->Glide.grStencilOpExt(stencilFailFunc,                                   stencilZFailFunc,                                   stencilZPassFunc);      fxMesa->Glide.grStencilFuncExt(ctx->Stencil.Function[face] - GL_NEVER + GR_CMP_NEVER,                                     ctx->Stencil.Ref[face],                                     ctx->Stencil.ValueMask[face]);      fxMesa->Glide.grStencilMaskExt(ctx->Stencil.WriteMask[face]);   } else {      grDisable(GR_STENCIL_MODE_EXT);   }}/************************************************************************//**************************** Color Mask SetUp **************************//************************************************************************/voidfxDDColorMask(GLcontext * ctx,	      GLboolean r, GLboolean g, GLboolean b, GLboolean a){   fxMesaContext fxMesa = FX_CONTEXT(ctx);   fxMesa->new_state |= FX_NEW_COLOR_MASK;   (void) r;   (void) g;   (void) b;   (void) a;}voidfxSetupColorMask(GLcontext * ctx){   fxMesaContext fxMesa = FX_CONTEXT(ctx);   if (fxMesa->colDepth == 32) {      /* 32bpp mode */      fxMesa->Glide.grColorMaskExt(ctx->Color.ColorMask[RCOMP],                                   ctx->Color.ColorMask[GCOMP],                                   ctx->Color.ColorMask[BCOMP],                                   ctx->Color.ColorMask[ACOMP] && fxMesa->haveHwAlpha);   }   else {      /* 15/16 bpp mode */      grColorMask(ctx->Color.ColorMask[RCOMP] |                  ctx->Color.ColorMask[GCOMP] |                  ctx->Color.ColorMask[BCOMP],                  ctx->Color.ColorMask[ACOMP] && fxMesa->haveHwAlpha);   }}/************************************************************************//**************************** Fog Mode SetUp ****************************//************************************************************************//* * This is called during state update in order to update the Glide fog state. */static voidfxSetupFog(GLcontext * ctx){   if (ctx->Fog.Enabled /*&& ctx->FogMode==FOG_FRAGMENT */ ) {      fxMesaContext fxMesa = FX_CONTEXT(ctx);      /* update fog color */      GLubyte col[4];      col[0] = (unsigned int) (255 * ctx->Fog.Color[0]);      col[1] = (unsigned int) (255 * ctx->Fog.Color[1]);      col[2] = (unsigned int) (255 * ctx->Fog.Color[2]);      col[3] = (unsigned int) (255 * ctx->Fog.Color[3]);      grFogColorValue(FXCOLOR4(col));      if (fxMesa->fogTableMode != ctx->Fog.Mode ||	  fxMesa->fogDensity != ctx->Fog.Density ||	  fxMesa->fogStart != ctx->Fog.Start ||	  fxMesa->fogEnd != ctx->Fog.End) {	 /* reload the fog table */	 switch (ctx->Fog.Mode) {	 case GL_LINEAR:	    guFogGenerateLinear(fxMesa->fogTable, ctx->Fog.Start,				ctx->Fog.End);	    if (fxMesa->fogTable[0] > 63) {	       /* [dBorca] Hack alert:	        * As per Glide3 Programming Guide:	        * The difference between consecutive fog values	        * must be less than 64.	        */	       fxMesa->fogTable[0] = 63;	    }	    break;	 case GL_EXP:	    guFogGenerateExp(fxMesa->fogTable, ctx->Fog.Density);	    break;	 case GL_EXP2:	    guFogGenerateExp2(fxMesa->fogTable, ctx->Fog.Density);	    break;	 default:	    ;	 }	 fxMesa->fogTableMode = ctx->Fog.Mode;	 fxMesa->fogDensity = ctx->Fog.Density;	 fxMesa->fogStart = ctx->Fog.Start;	 fxMesa->fogEnd = ctx->Fog.End;      }      grFogTable(fxMesa->fogTable);      if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) {         grVertexLayout(GR_PARAM_FOG_EXT, GR_VERTEX_FOG_OFFSET << 2,                                          GR_PARAM_ENABLE);         grFogMode(GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT);      } else {         grVertexLayout(GR_PARAM_FOG_EXT, GR_VERTEX_FOG_OFFSET << 2,                                          GR_PARAM_DISABLE);         grFogMode(GR_FOG_WITH_TABLE_ON_Q);      }   }   else {      grFogMode(GR_FOG_DISABLE);   }}voidfxDDFogfv(GLcontext * ctx, GLenum pname, const GLfloat * params){   FX_CONTEXT(ctx)->new_state |= FX_NEW_FOG;   switch (pname) {      case GL_FOG_COORDINATE_SOURCE_EXT: {         GLenum p = (GLenum)*params;         if (p == GL_FOG_COORDINATE_EXT) {            _swrast_allow_vertex_fog(ctx, GL_TRUE);            _swrast_allow_pixel_fog(ctx, GL_FALSE);            _tnl_allow_vertex_fog( ctx, GL_TRUE);            _tnl_allow_pixel_fog( ctx, GL_FALSE);         } else {            _swrast_allow_vertex_fog(ctx, GL_FALSE);            _swrast_allow_pixel_fog(ctx, GL_TRUE);            _tnl_allow_vertex_fog( ctx, GL_FALSE);            _tnl_allow_pixel_fog( ctx, GL_TRUE);         }         break;      }      default:         ;   }}/************************************************************************//************************** Scissor Test SetUp **************************//************************************************************************//* This routine is used in managing the lock state, and therefore can't lock */voidfxSetScissorValues(GLcontext * ctx){   fxMesaContext fxMesa = FX_CONTEXT(ctx);   int xmin, xmax;   int ymin, ymax;   if (ctx->Scissor.Enabled) {      xmin = ctx->Scissor.X;      xmax = ctx->Scissor.X + ctx->Scissor.Width;      ymin = ctx->Scissor.Y;      ymax = ctx->Scissor.Y + ctx->Scissor.Height;      if (xmin < 0)         xmin = 0;      if (xmax > fxMesa->width)         xmax = fxMesa->width;      if (ymin < fxMesa->screen_height - fxMesa->height)         ymin = fxMesa->screen_height - fxMesa->height;      if (ymax > fxMesa->screen_height - 0)         ymax = fxMesa->screen_height - 0;   }   else {      xmin = 0;      ymin = 0;      xmax = fxMesa->width;      ymax = fxMesa->height;   }   fxMesa->clipMinX = xmin;   fxMesa->clipMinY = ymin;   fxMesa->clipMaxX = xmax;   fxMesa->clipMaxY = ymax;   grClipWindow(xmin, ymin, xmax, ymax);}voidfxSetupScissor(GLcontext * ctx){   BEGIN_BOARD_LOCK();   fxSetScissorValues(ctx);   END_BOARD_LOCK();}voidfxDDScissor(GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h){   FX_CONTEXT(ctx)->new_state |= FX_NEW_SCISSOR;}/************************************************************************//*************************** Cull mode setup ****************************//************************************************************************/voidfxDDCullFace(GLcontext * ctx, GLenum mode){   (void) mode;   FX_CONTEXT(ctx)->new_state |= FX_NEW_CULL;}voidfxDDFrontFace(GLcontext * ctx, GLenum mode){   (void) mode;   FX_CONTEXT(ctx)->new_state |= FX_NEW_CULL;}voidfxSetupCull(GLcontext * ctx){   fxMesaContext fxMesa = FX_CONTEXT(ctx);   GrCullMode_t mode = GR_CULL_DISABLE;   if (ctx->Polygon.CullFlag && (fxMesa->raster_primitive == GL_TRIANGLES)) {      switch (ctx->Polygon.CullFaceMode) {      case GL_BACK:	 if (ctx->Polygon.FrontFace == GL_CCW)	    mode = GR_CULL_NEGATIVE;	 else	    mode = GR_CULL_POSITIVE;	 break;      case GL_FRONT:	 if (ctx->Polygon.FrontFace == GL_CCW)	    mode = GR_CULL_POSITIVE;	 else	    mode = GR_CULL_NEGATIVE;	 break;      case GL_FRONT_AND_BACK:	 /* Handled as a fallback on triangles in tdfx_tris.c */	 return;      default:	 ASSERT(0);	 break;      }   }   if (fxMesa->cullMode != mode) {      fxMesa->cullMode = mode;      grCullMode(mode);   }}/************************************************************************//****************************** DD Enable ******************************//************************************************************************/voidfxDDEnable(GLcontext * ctx, GLenum cap, GLboolean state){   fxMesaContext fxMesa = FX_CONTEXT(ctx);   tfxUnitsState *us = &fxMesa->unitsState;   if (TDFX_DEBUG & VERBOSE_DRIVER) {      fprintf(stderr, "%s(%s)\n", state ? "fxDDEnable" : "fxDDDisable",	      _mesa_lookup_enum_by_nr(cap));   }   switch (cap) {   case GL_ALPHA_TEST:      if (state != us->alphaTestEnabled) {	 us->alphaTestEnabled = state;	 fxMesa->new_state |= FX_NEW_ALPHA;

⌨️ 快捷键说明

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