}
+/**
+ * Setup hardware bits for new texture environment settings.
+ *
+ * \todo
+ * Determine whether or not \c param can be used instead of
+ * \c texUnit->EnvColor in the \c GL_TEXTURE_ENV_COLOR case.
+ */
static void i810TexEnv( GLcontext *ctx, GLenum target,
GLenum pname, const GLfloat *param )
{
i810ContextPtr imesa = I810_CONTEXT( ctx );
- GLuint unit = ctx->Texture.CurrentUnit;
+ const GLuint unit = ctx->Texture.CurrentUnit;
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
/* Only one env color. Need a fallback if env colors are different
* and texture setup references env color in both units.
*/
switch (pname) {
case GL_TEXTURE_ENV_COLOR: {
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
- GLfloat *fc = texUnit->EnvColor;
- GLuint r, g, b, a, col;
- CLAMPED_FLOAT_TO_UBYTE(r, fc[0]);
- CLAMPED_FLOAT_TO_UBYTE(g, fc[1]);
- CLAMPED_FLOAT_TO_UBYTE(b, fc[2]);
- CLAMPED_FLOAT_TO_UBYTE(a, fc[3]);
-
- col = ((a << 24) |
- (r << 16) |
- (g << 8) |
- (b << 0));
-
- if (imesa->Setup[I810_CTXREG_CF1] != col) {
- I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
- imesa->Setup[I810_CTXREG_CF1] = col;
+ GLubyte c[4];
+ GLuint envColor;
+
+ UNCLAMPED_FLOAT_TO_RGBA_CHAN( c, texUnit->EnvColor );
+ envColor = PACK_COLOR_8888( c[3], c[0], c[1], c[2] );
+
+ if (imesa->Setup[I810_CTXREG_CF1] != envColor) {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_CF1] = envColor;
}
break;
}
+
case GL_TEXTURE_ENV_MODE:
imesa->TexEnvImageFmt[unit] = 0; /* force recalc of env state */
break;
- case GL_TEXTURE_LOD_BIAS_EXT:
- {
- struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
- i810TextureObjectPtr t = (i810TextureObjectPtr) tObj->DriverData;
- t->Setup[I810_TEXREG_MLC] &= ~(MLC_LOD_BIAS_MASK);
- t->Setup[I810_TEXREG_MLC] |= i810ComputeLodBias(*param);
+ case GL_TEXTURE_LOD_BIAS: {
+ if ( texUnit->_Current != NULL ) {
+ const struct gl_texture_object *tObj = texUnit->_Current;
+ i810TextureObjectPtr t = (i810TextureObjectPtr) tObj->DriverData;
+
+ t->Setup[I810_TEXREG_MLC] &= ~(MLC_LOD_BIAS_MASK);
+ t->Setup[I810_TEXREG_MLC] |= i810ComputeLodBias(*param);
}
break;
+ }
default:
break;