static void update_texgen(struct gl_context *ctx) { GLuint unit; /* Setup texgen for those texture coordinate sets that are in use */ for (unit = 0; unit < ctx->Const.MaxTextureCoordUnits; unit++) { struct gl_fixedfunc_texture_unit *texUnit = &ctx->Texture.FixedFuncUnit[unit]; texUnit->_GenFlags = 0x0; if (!(ctx->Texture._EnabledCoordUnits & (1 << unit))) continue; if (texUnit->TexGenEnabled) { if (texUnit->TexGenEnabled & S_BIT) { texUnit->_GenFlags |= texUnit->GenS._ModeBit; } if (texUnit->TexGenEnabled & T_BIT) { texUnit->_GenFlags |= texUnit->GenT._ModeBit; } if (texUnit->TexGenEnabled & R_BIT) { texUnit->_GenFlags |= texUnit->GenR._ModeBit; } if (texUnit->TexGenEnabled & Q_BIT) { texUnit->_GenFlags |= texUnit->GenQ._ModeBit; } ctx->Texture._TexGenEnabled |= ENABLE_TEXGEN(unit); ctx->Texture._GenFlags |= texUnit->_GenFlags; } assert(unit < ARRAY_SIZE(ctx->TextureMatrixStack)); if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY) ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(unit); } }
/* Note: This routine refers to derived texture matrix values to * compute the ENABLE_TEXMAT flags, but is only called on * _NEW_TEXTURE. On changes to _NEW_TEXTURE_MATRIX, the ENABLE_TEXMAT * flags are updated by _mesa_update_texture_matrices, above. * * If both TEXTURE and TEXTURE_MATRIX change at once, these values * will be computed twice. */ static void update_texture_state( GLcontext *ctx ) { GLuint i; ctx->Texture._ReallyEnabled = 0; ctx->Texture._GenFlags = 0; ctx->_NeedNormals &= ~NEED_NORMALS_TEXGEN; ctx->_NeedEyeCoords &= ~NEED_EYE_TEXGEN; ctx->Texture._TexMatEnabled = 0; ctx->Texture._TexGenEnabled = 0; /* Update texture unit state. */ for (i=0; i < ctx->Const.MaxTextureUnits; i++) { struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; texUnit->_ReallyEnabled = 0; texUnit->_GenFlags = 0; if (!texUnit->Enabled) continue; /* Find the texture of highest dimensionality that is enabled * and complete. We'll use it for texturing. */ if (texUnit->Enabled & TEXTURE0_CUBE) { struct gl_texture_object *texObj = texUnit->CurrentCubeMap; if (!texObj->Complete) { _mesa_test_texobj_completeness(ctx, texObj); } if (texObj->Complete) { texUnit->_ReallyEnabled = TEXTURE0_CUBE; texUnit->_Current = texObj; } } if (!texUnit->_ReallyEnabled && (texUnit->Enabled & TEXTURE0_3D)) { struct gl_texture_object *texObj = texUnit->Current3D; if (!texObj->Complete) { _mesa_test_texobj_completeness(ctx, texObj); } if (texObj->Complete) { texUnit->_ReallyEnabled = TEXTURE0_3D; texUnit->_Current = texObj; } } if (!texUnit->_ReallyEnabled && (texUnit->Enabled & TEXTURE0_RECT)) { struct gl_texture_object *texObj = texUnit->CurrentRect; if (!texObj->Complete) { _mesa_test_texobj_completeness(ctx, texObj); } if (texObj->Complete) { texUnit->_ReallyEnabled = TEXTURE0_RECT; texUnit->_Current = texObj; } } if (!texUnit->_ReallyEnabled && (texUnit->Enabled & TEXTURE0_2D)) { struct gl_texture_object *texObj = texUnit->Current2D; if (!texObj->Complete) { _mesa_test_texobj_completeness(ctx, texObj); } if (texObj->Complete) { texUnit->_ReallyEnabled = TEXTURE0_2D; texUnit->_Current = texObj; } } if (!texUnit->_ReallyEnabled && (texUnit->Enabled & TEXTURE0_1D)) { struct gl_texture_object *texObj = texUnit->Current1D; if (!texObj->Complete) { _mesa_test_texobj_completeness(ctx, texObj); } if (texObj->Complete) { texUnit->_ReallyEnabled = TEXTURE0_1D; texUnit->_Current = texObj; } } if (!texUnit->_ReallyEnabled) { texUnit->_Current = NULL; continue; } { GLuint flag = texUnit->_ReallyEnabled << (i * NUM_TEXTURE_TARGETS); ctx->Texture._ReallyEnabled |= flag; } if (texUnit->TexGenEnabled) { if (texUnit->TexGenEnabled & S_BIT) { texUnit->_GenFlags |= texUnit->_GenBitS; } if (texUnit->TexGenEnabled & T_BIT) { texUnit->_GenFlags |= texUnit->_GenBitT; } if (texUnit->TexGenEnabled & Q_BIT) { texUnit->_GenFlags |= texUnit->_GenBitQ; } if (texUnit->TexGenEnabled & R_BIT) { texUnit->_GenFlags |= texUnit->_GenBitR; } ctx->Texture._TexGenEnabled |= ENABLE_TEXGEN(i); ctx->Texture._GenFlags |= texUnit->_GenFlags; } if (ctx->TextureMatrix[i].type != MATRIX_IDENTITY) ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(i); } if (ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS) { ctx->_NeedNormals |= NEED_NORMALS_TEXGEN; ctx->_NeedEyeCoords |= NEED_EYE_TEXGEN; } if (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD) { ctx->_NeedEyeCoords |= NEED_EYE_TEXGEN; } }