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

📄 fxsetup.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 5 页
字号:
	    tmu0 = 1;	    tmu1 = 0;	 }	 else {			/* Nothing is loaded */	    fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU0);	    fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU1);	    /* tmu0 and tmu1 are setup */	 }      }   }   /* [dBorca] Hack alert:    * we put these in reverse order, so that if we can't    * do _REAL_ pointcast, the TMU0 table gets broadcasted    */   if (!fxMesa->haveGlobalPaletteTexture) {      /* pointcast */      if (ti1->info.format == GR_TEXFMT_P_8) {	 if (TDFX_DEBUG & VERBOSE_DRIVER) {	    fprintf(stderr, "fxSetupDoubleTMU_NoLock: uploading texture palette for TMU1\n");	 }	 fxMesa->Glide.grTexDownloadTableExt(ti1->whichTMU, ti1->paltype, &(ti1->palette));      }      if (ti0->info.format == GR_TEXFMT_P_8) {	 if (TDFX_DEBUG & VERBOSE_DRIVER) {	    fprintf(stderr, "fxSetupDoubleTMU_NoLock: uploading texture palette for TMU0\n");	 }	 fxMesa->Glide.grTexDownloadTableExt(ti0->whichTMU, ti0->paltype, &(ti0->palette));      }   }   grTexSource(tmu0, ti0->tm[tmu0]->startAddr,			 GR_MIPMAPLEVELMASK_BOTH, &(ti0->info));   grTexClampMode(tmu0, ti0->sClamp, ti0->tClamp);   grTexFilterMode(tmu0, ti0->minFilt, ti0->maxFilt);   grTexMipMapMode(tmu0, ti0->mmMode, FXFALSE);   grTexSource(tmu1, ti1->tm[tmu1]->startAddr,			 GR_MIPMAPLEVELMASK_BOTH, &(ti1->info));   grTexClampMode(tmu1, ti1->sClamp, ti1->tClamp);   grTexFilterMode(tmu1, ti1->minFilt, ti1->maxFilt);   grTexMipMapMode(tmu1, ti1->mmMode, FXFALSE);#undef T0_NOT_IN_TMU#undef T1_NOT_IN_TMU#undef T0_IN_TMU0#undef T1_IN_TMU0#undef T0_IN_TMU1#undef T1_IN_TMU1}static voidfxSetupTextureDoubleTMU_NoLock(GLcontext * ctx){   fxMesaContext fxMesa = FX_CONTEXT(ctx);   struct tdfx_combine alphaComb, colorComb;   struct tdfx_texcombine tex0, tex1;   GrCombineLocal_t localc, locala;   tfxTexInfo *ti0, *ti1;   struct gl_texture_object *tObj0 = ctx->Texture.Unit[1]._Current;   struct gl_texture_object *tObj1 = ctx->Texture.Unit[0]._Current;   GLuint envmode, ifmt, unitsmode;   int tmu0 = 0, tmu1 = 1;   if (TDFX_DEBUG & VERBOSE_DRIVER) {      fprintf(stderr, "fxSetupTextureDoubleTMU_NoLock(...)\n");   }   ti0 = fxTMGetTexInfo(tObj0);   fxTexValidate(ctx, tObj0);   ti1 = fxTMGetTexInfo(tObj1);   fxTexValidate(ctx, tObj1);   fxSetupDoubleTMU_NoLock(fxMesa, tObj0, tObj1);   unitsmode = fxGetTexSetConfiguration(ctx, tObj0, tObj1);/*    if(fxMesa->lastUnitsMode==unitsmode) *//*      return; */   fxMesa->lastUnitsMode = unitsmode;   fxMesa->stw_hint_state |= GR_STWHINT_ST_DIFF_TMU1;   FX_grHints_NoLock(GR_HINT_STWHINT, fxMesa->stw_hint_state);   envmode = unitsmode & FX_UM_E_ENVMODE;   ifmt = unitsmode & FX_UM_E_IFMT;   if (unitsmode & FX_UM_ALPHA_ITERATED)      locala = GR_COMBINE_LOCAL_ITERATED;   else      locala = GR_COMBINE_LOCAL_CONSTANT;   if (unitsmode & FX_UM_COLOR_ITERATED)      localc = GR_COMBINE_LOCAL_ITERATED;   else      localc = GR_COMBINE_LOCAL_CONSTANT;   if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE))      fprintf(stderr, "fxSetupTextureDoubleTMU_NoLock: envmode is %s/%s\n",	      _mesa_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode),	      _mesa_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode));   if ((ti0->whichTMU == FX_TMU1) || (ti1->whichTMU == FX_TMU0)) {      tmu0 = 1;      tmu1 = 0;   }   fxMesa->tmuSrc = FX_TMU_BOTH;   tex0.InvertRGB     = FXFALSE;   tex0.InvertAlpha   = FXFALSE;   tex1.InvertRGB     = FXFALSE;   tex1.InvertAlpha   = FXFALSE;   alphaComb.Local    = locala;   alphaComb.Invert   = FXFALSE;   colorComb.Local    = localc;   colorComb.Invert   = FXFALSE;   switch (envmode) {   case (FX_UM_E0_MODULATE | FX_UM_E1_MODULATE):      {	 GLboolean isalpha[FX_NUM_TMU];	 isalpha[tmu0] = (ti0->baseLevelInternalFormat == GL_ALPHA);	 isalpha[tmu1] = (ti1->baseLevelInternalFormat == GL_ALPHA);	 if (isalpha[FX_TMU1]) {            tex1.FunctionRGB   = GR_COMBINE_FUNCTION_ZERO;            tex1.FactorRGB     = GR_COMBINE_FACTOR_NONE;            tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;            tex1.FactorAlpha   = GR_COMBINE_FACTOR_NONE;            tex1.InvertRGB     = FXTRUE;	 } else {            tex1.FunctionRGB   = GR_COMBINE_FUNCTION_LOCAL;            tex1.FactorRGB     = GR_COMBINE_FACTOR_NONE;            tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;            tex1.FactorAlpha   = GR_COMBINE_FACTOR_NONE;         }	 if (isalpha[FX_TMU0]) {            tex0.FunctionRGB   = GR_COMBINE_FUNCTION_BLEND_OTHER;            tex0.FactorRGB     = GR_COMBINE_FACTOR_ONE;            tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER;            tex0.FactorAlpha   = GR_COMBINE_FACTOR_LOCAL;	 } else {            tex0.FunctionRGB   = GR_COMBINE_FUNCTION_BLEND_OTHER;            tex0.FactorRGB     = GR_COMBINE_FACTOR_LOCAL;            tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER;            tex0.FactorAlpha   = GR_COMBINE_FACTOR_LOCAL;         }         colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;         colorComb.Factor   = GR_COMBINE_FACTOR_LOCAL;         colorComb.Other    = GR_COMBINE_OTHER_TEXTURE;         alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;         alphaComb.Factor   = GR_COMBINE_FACTOR_LOCAL;         alphaComb.Other    = GR_COMBINE_OTHER_TEXTURE;	 break;      }   case (FX_UM_E0_REPLACE | FX_UM_E1_BLEND):	/* Only for GLQuake */      if (tmu0 == FX_TMU1) {         tex1.FunctionRGB   = GR_COMBINE_FUNCTION_LOCAL;         tex1.FactorRGB     = GR_COMBINE_FACTOR_NONE;         tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;         tex1.FactorAlpha   = GR_COMBINE_FACTOR_NONE;         tex1.InvertRGB     = FXTRUE;         tex0.FunctionRGB   = GR_COMBINE_FUNCTION_BLEND_OTHER;         tex0.FactorRGB     = GR_COMBINE_FACTOR_LOCAL;         tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER;         tex0.FactorAlpha   = GR_COMBINE_FACTOR_LOCAL;      }      else {         tex1.FunctionRGB   = GR_COMBINE_FUNCTION_LOCAL;         tex1.FactorRGB     = GR_COMBINE_FACTOR_NONE;         tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;         tex1.FactorAlpha   = GR_COMBINE_FACTOR_NONE;         tex0.FunctionRGB   = GR_COMBINE_FUNCTION_BLEND_OTHER;         tex0.FactorRGB     = GR_COMBINE_FACTOR_ONE_MINUS_LOCAL;         tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER;         tex0.FactorAlpha   = GR_COMBINE_FACTOR_ONE_MINUS_LOCAL;      }      alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL;      alphaComb.Factor   = GR_COMBINE_FACTOR_NONE;      alphaComb.Other    = GR_COMBINE_OTHER_NONE;      colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;      colorComb.Factor   = GR_COMBINE_FACTOR_ONE;      colorComb.Other    = GR_COMBINE_OTHER_TEXTURE;      break;   case (FX_UM_E0_REPLACE | FX_UM_E1_MODULATE):	/* Quake 2 and 3 */      if (tmu1 == FX_TMU1) {         tex1.FunctionRGB   = GR_COMBINE_FUNCTION_LOCAL;         tex1.FactorRGB     = GR_COMBINE_FACTOR_NONE;         tex1.FunctionAlpha = GR_COMBINE_FUNCTION_ZERO;         tex1.FactorAlpha   = GR_COMBINE_FACTOR_NONE;         tex1.InvertAlpha   = FXTRUE;         tex0.FunctionRGB   = GR_COMBINE_FUNCTION_BLEND_OTHER;         tex0.FactorRGB     = GR_COMBINE_FACTOR_LOCAL;         tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER;         tex0.FactorAlpha   = GR_COMBINE_FACTOR_LOCAL;      }      else {         tex1.FunctionRGB   = GR_COMBINE_FUNCTION_LOCAL;         tex1.FactorRGB     = GR_COMBINE_FACTOR_NONE;         tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;         tex1.FactorAlpha   = GR_COMBINE_FACTOR_NONE;         tex0.FunctionRGB   = GR_COMBINE_FUNCTION_BLEND_OTHER;         tex0.FactorRGB     = GR_COMBINE_FACTOR_LOCAL;         tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER;         tex0.FactorAlpha   = GR_COMBINE_FACTOR_ONE;      }      if (ti0->baseLevelInternalFormat == GL_RGB) {         alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL;         alphaComb.Factor   = GR_COMBINE_FACTOR_NONE;         alphaComb.Other    = GR_COMBINE_OTHER_NONE;      } else {         alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;         alphaComb.Factor   = GR_COMBINE_FACTOR_ONE;         alphaComb.Other    = GR_COMBINE_OTHER_NONE;      }      colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;      colorComb.Factor   = GR_COMBINE_FACTOR_ONE;      colorComb.Other    = GR_COMBINE_OTHER_TEXTURE;      break;   case (FX_UM_E0_MODULATE | FX_UM_E1_ADD):	/* Quake 3 Sky */      {	 GLboolean isalpha[FX_NUM_TMU];	 isalpha[tmu0] = (ti0->baseLevelInternalFormat == GL_ALPHA);	 isalpha[tmu1] = (ti1->baseLevelInternalFormat == GL_ALPHA);	 if (isalpha[FX_TMU1]) {            tex1.FunctionRGB   = GR_COMBINE_FUNCTION_ZERO;            tex1.FactorRGB     = GR_COMBINE_FACTOR_NONE;            tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;            tex1.FactorAlpha   = GR_COMBINE_FACTOR_NONE;            tex1.InvertRGB     = FXTRUE;	 } else {            tex1.FunctionRGB   = GR_COMBINE_FUNCTION_LOCAL;            tex1.FactorRGB     = GR_COMBINE_FACTOR_NONE;            tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;            tex1.FactorAlpha   = GR_COMBINE_FACTOR_NONE;         }	 if (isalpha[FX_TMU0]) {            tex0.FunctionRGB   = GR_COMBINE_FUNCTION_SCALE_OTHER;            tex0.FactorRGB     = GR_COMBINE_FACTOR_ONE;            tex0.FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;            tex0.FactorAlpha   = GR_COMBINE_FACTOR_ONE;	 } else {            tex0.FunctionRGB   = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;            tex0.FactorRGB     = GR_COMBINE_FACTOR_ONE;            tex0.FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;            tex0.FactorAlpha   = GR_COMBINE_FACTOR_ONE;         }         colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;         colorComb.Factor   = GR_COMBINE_FACTOR_LOCAL;         colorComb.Other    = GR_COMBINE_OTHER_TEXTURE;         alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;         alphaComb.Factor   = GR_COMBINE_FACTOR_LOCAL;         alphaComb.Other    = GR_COMBINE_OTHER_TEXTURE;	 break;      }   case (FX_UM_E0_REPLACE | FX_UM_E1_ADD):	/* Vulpine Sky */      {	 GLboolean isalpha[FX_NUM_TMU];	 isalpha[tmu0] = (ti0->baseLevelInternalFormat == GL_ALPHA);	 isalpha[tmu1] = (ti1->baseLevelInternalFormat == GL_ALPHA);	 if (isalpha[FX_TMU1]) {            tex1.FunctionRGB   = GR_COMBINE_FUNCTION_ZERO;            tex1.FactorRGB     = GR_COMBINE_FACTOR_NONE;            tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;            tex1.FactorAlpha   = GR_COMBINE_FACTOR_NONE;            tex1.InvertRGB     = FXTRUE;	 } else {            tex1.FunctionRGB   = GR_COMBINE_FUNCTION_LOCAL;            tex1.FactorRGB     = GR_COMBINE_FACTOR_NONE;            tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;            tex1.FactorAlpha   = GR_COMBINE_FACTOR_NONE;         }	 if (isalpha[FX_TMU0]) {            tex0.FunctionRGB   = GR_COMBINE_FUNCTION_SCALE_OTHER;            tex0.FactorRGB     = GR_COMBINE_FACTOR_ONE;            tex0.FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;            tex0.FactorAlpha   = GR_COMBINE_FACTOR_ONE;	 } else {            tex0.FunctionRGB   = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;            tex0.FactorRGB     = GR_COMBINE_FACTOR_ONE;            tex0.FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;            tex0.FactorAlpha   = GR_COMBINE_FACTOR_ONE;         }         colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;         colorComb.Factor   = GR_COMBINE_FACTOR_ONE;         colorComb.Other    = GR_COMBINE_OTHER_TEXTURE;         alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;         alphaComb.Factor   = GR_COMBINE_FACTOR_ONE;         alphaComb.Other    = GR_COMBINE_OTHER_TEXTURE;	 break;      }   case (FX_UM_E0_MODULATE | FX_UM_E1_REPLACE): /* Homeworld2 */      {         tex1.FunctionRGB   = GR_COMBINE_FUNCTION_ZERO;         tex1.FactorRGB     = GR_COMBINE_FACTOR_NONE;         tex1.FunctionAlpha = GR_COMBINE_FUNCTION_ZERO;         tex1.FactorAlpha   = GR_COMBINE_FACTOR_NONE;         tex0.FunctionRGB   = GR_COMBINE_FUNCTION_LOCAL;         tex0.FactorRGB     = GR_COMBINE_FACTOR_NONE;         tex0.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;         tex0.FactorAlpha   = GR_COMBINE_FACTOR_NONE;         if (ifmt & (FX_UM_E0_RGB | FX_UM_E0_LUMINANCE)) {            alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL;            alphaComb.Factor   = GR_COMBINE_FACTOR_NONE;            alphaComb.Other    = GR_COMBINE_OTHER_NONE;         } else {            alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;            alphaComb.Factor   = GR_COMBINE_FACTOR_ONE;            alphaComb.Other    = GR_COMBINE_OTHER_TEXTURE;         }         if (ifmt & FX_UM_E0_ALPHA) {            colorComb.Function = GR_COMBINE_FUNCTION_LOCAL;            colorComb.Factor   = GR_COMBINE_FACTOR_NONE;            colorComb.Other    = GR_COMBINE_OTHER_NONE;         } else {            colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;            colorComb.Factor   = GR_COMBINE_FACTOR_ONE;            colorComb.Other    = GR_COMBINE_OTHER_TEXTURE;         }         break;      }   default:      fprintf(stderr, "fxSetupTextureDoubleTMU_NoLock: Unexpected dual texture mode encountered\n");      return;   }   grAlphaCombine(alphaComb.Function,                  alphaComb.Factor,                  alphaComb.Local,                  alphaComb.Other,                  alphaComb.Invert);   grColorCombine(colorComb.Function,                  colorComb.Factor,                  colorComb.Local,                  colorComb.Other,                  colorComb.Invert);   grTexCombine(GR_TMU0,                tex0.FunctionRGB,                tex0.FactorRGB,                tex0.FunctionAlpha,                tex0.FactorAlpha,                tex0.InvertRGB,                tex0.InvertAlpha);   grTexCombine(GR_TMU1,                tex1.FunctionRGB,                tex1.FactorRGB,                tex1.FunctionAlpha,                tex1.FactorAlpha,                tex1.InvertRGB,                tex1.InvertAlpha);}/************************* No Texture ***************************/static voidfxSetupTextureNone_NoLock(GLcontext * ctx){   fxMesaContext fxMesa = FX_CONTEXT(ctx);   GrCombineLocal_t localc, locala;   if (TDFX_DEBUG & VERBOSE_DRIVER) {      fprintf(stderr, "fxSetupTextureNone_NoLock(...)\n");   }   if ((ctx->Light.ShadeModel == GL_SMOOTH) || 1 ||       (ctx->Point.SmoothFlag) ||       (ctx->Line.SmoothFlag) ||       (ctx->Polygon.SmoothFlag)) locala = GR_COMBINE_LOCAL_ITERATED;   else      locala = GR_COMBINE_LOCAL_CONSTANT;   if (ctx->Light.ShadeModel == GL_SMOOTH || 1)      localc = GR_COMBINE_LOCAL_ITERATED;   else      localc = GR_COMBINE_LOCAL_CONSTANT;   grAlphaCombine(GR_COMBINE_FUNCTION_LOCAL,                  GR_COMBINE_FACTOR_NONE,                  locala,                  GR_COMBINE_OTHER_NONE,                  FXFALSE);

⌨️ 快捷键说明

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