added GL_EXT_texture_env_combine (Holger Waechtler)
authorBrian Paul <brian.paul@tungstengraphics.com>
Tue, 27 Jun 2000 21:42:13 +0000 (21:42 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Tue, 27 Jun 2000 21:42:13 +0000 (21:42 +0000)
src/mesa/drivers/osmesa/osmesa.c
src/mesa/main/context.c
src/mesa/main/drawpix.c
src/mesa/main/enums.c
src/mesa/main/extensions.c
src/mesa/main/texstate.c

index 081dbc4e190083054dac9238c0140f86467e7ecb..56059607118e81e0ac8020793c0312a80d7296cf 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: osmesa.c,v 1.18 2000/05/26 16:17:00 brianp Exp $ */
+/* $Id: osmesa.c,v 1.19 2000/06/27 21:42:14 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -226,6 +226,7 @@ OSMesaCreateContext( GLenum format, OSMesaContext sharelist )
       }
       gl_extensions_enable(&(osmesa->gl_ctx),"GL_HP_occlusion_test");
       gl_extensions_enable(&(osmesa->gl_ctx), "GL_ARB_texture_cube_map");
+      gl_extensions_enable(&(osmesa->gl_ctx), "GL_EXT_texture_env_combine");
 
       osmesa->gl_buffer = gl_create_framebuffer( osmesa->gl_visual,
                                            osmesa->gl_visual->DepthBits > 0,
index d17897a7dff533c9fcfbb5174e8925a2e3ad6ef7..7ed7f12425fed1353c85068a29bea4c2f01f1b97 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.71 2000/06/27 04:29:22 brianp Exp $ */
+/* $Id: context.c,v 1.72 2000/06/27 21:42:13 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -594,6 +594,23 @@ init_texture_unit( GLcontext *ctx, GLuint unit )
    struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
 
    texUnit->EnvMode = GL_MODULATE;
+   texUnit->CombineModeRGB = GL_MODULATE;
+   texUnit->CombineModeA = GL_MODULATE;
+   texUnit->CombineSourceRGB[0] = GL_TEXTURE;
+   texUnit->CombineSourceRGB[1] = GL_PREVIOUS_EXT;
+   texUnit->CombineSourceRGB[2] = GL_CONSTANT_EXT;
+   texUnit->CombineSourceA[0] = GL_TEXTURE;
+   texUnit->CombineSourceA[1] = GL_PREVIOUS_EXT;
+   texUnit->CombineSourceA[2] = GL_CONSTANT_EXT;
+   texUnit->CombineOperandRGB[0] = GL_SRC_COLOR;
+   texUnit->CombineOperandRGB[1] = GL_SRC_COLOR;
+   texUnit->CombineOperandRGB[2] = GL_SRC_ALPHA;
+   texUnit->CombineOperandA[0] = GL_SRC_ALPHA;
+   texUnit->CombineOperandA[1] = GL_SRC_ALPHA;
+   texUnit->CombineOperandA[2] = GL_SRC_ALPHA;
+   texUnit->CombineScaleShiftRGB = 0;
+   texUnit->CombineScaleShiftA = 0;
+
    ASSIGN_4V( texUnit->EnvColor, 0.0, 0.0, 0.0, 0.0 );
    texUnit->TexGenEnabled = 0;
    texUnit->GenModeS = GL_EYE_LINEAR;
index a7f309029d659b5a7c957a7085268d64b135f626..36e8af3b9394c68331e2aedff450c1241ca454c5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drawpix.c,v 1.23 2000/06/27 04:32:16 brianp Exp $ */
+/* $Id: drawpix.c,v 1.24 2000/06/27 21:42:13 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -658,12 +658,17 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
 
          if (ctx->Texture.ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
             GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH];
+            GLubyte primary_rgba[MAX_WIDTH][4];
             GLuint unit;
             /* XXX not sure how multitexture is supposed to work here */
+
+            MEMCPY(primary_rgba, rgba, 4 * width * sizeof(GLubyte));
+
             for (unit = 0; unit < MAX_TEXTURE_UNITS; unit++) {
                _mesa_pixeltexgen(ctx, width, (const GLubyte (*)[4]) rgba,
                                  s, t, r, q);
-               gl_texture_pixels(ctx, unit, width, s, t, r, NULL, rgba);
+               gl_texture_pixels(ctx, unit, width, s, t, r, NULL,
+                                 primary_rgba, rgba);
             }
          }
 
index 417a76bf3e8482144276caf790acd5b9a239d716..bdf247fecf9d54f1e9392b1c72e9ff701e142f70 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: enums.c,v 1.8 2000/03/28 16:59:39 rjfrank Exp $ */
+/* $Id: enums.c,v 1.9 2000/06/27 21:42:13 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -805,7 +805,30 @@ enum_elt all_enums[] =
    { "GL_ARRAY_ELEMENT_LOCK_COUNT_EXT", 0x81A9},
 
    /* GL_EXT_clip_volume_hint */
-   { "GL_CLIP_VOLUME_CLIPPING_HINT_EXT", 0x80F0}
+   { "GL_CLIP_VOLUME_CLIPPING_HINT_EXT", 0x80F0},
+
+   /* GL_EXT_texture_env_combine */
+   { "GL_COMBINE_EXT", 0x8570 },
+   { "GL_COMBINE_RGB_EXT", 0x8571 },
+   { "GL_COMBINE_ALPHA_EXT", 0x8572 },
+   { "GL_SOURCE0_RGB_EXT", 0x8580 },
+   { "GL_SOURCE1_RGB_EXT", 0x8581 },
+   { "GL_SOURCE2_RGB_EXT", 0x8582 },
+   { "GL_SOURCE0_ALPHA_EXT", 0x8588 },
+   { "GL_SOURCE1_ALPHA_EXT", 0x8589 },
+   { "GL_SOURCE2_ALPHA_EXT", 0x858A },
+   { "GL_OPERAND0_RGB_EXT", 0x8590 },
+   { "GL_OPERAND1_RGB_EXT", 0x8591 },
+   { "GL_OPERAND2_RGB_EXT", 0x8592 },
+   { "GL_OPERAND0_ALPHA_EXT", 0x8598 },
+   { "GL_OPERAND1_ALPHA_EXT", 0x8599 },
+   { "GL_OPERAND2_ALPHA_EXT", 0x859A },
+   { "GL_RGB_SCALE_EXT", 0x8573 },
+   { "GL_ADD_SIGNED_EXT", 0x8574 },
+   { "GL_INTERPOLATE_EXT", 0x8575 },
+   { "GL_CONSTANT_EXT", 0x8576 },
+   { "GL_PRIMARY_COLOR_EXT", 0x8577 },
+   { "GL_PREVIOUS_EXT", 0x8578 }
 
 };
 
index 32af093bac1b2fc9a082ca209e5ddab9437dd51f..5d4ad1bb9e4e4aad5a605fdc5d2e919b981be434 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: extensions.c,v 1.31 2000/06/08 22:47:24 brianp Exp $ */
+/* $Id: extensions.c,v 1.32 2000/06/27 21:42:13 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -75,6 +75,7 @@ static struct { int enabled; const char *name; } default_extensions[] = {
    { DEFAULT_OFF,    "GL_EXT_texture_compression_s3tc" },
    { DEFAULT_OFF,    "GL_EXT_texture_env" },
    { DEFAULT_ON,     "GL_EXT_texture_env_add" },
+   { DEFAULT_OFF,    "GL_EXT_texture_env_combine" },
    { ALWAYS_ENABLED, "GL_EXT_texture_object" },
    { DEFAULT_ON,     "GL_EXT_texture_lod_bias" },
    { ALWAYS_ENABLED, "GL_EXT_vertex_array" },
@@ -103,6 +104,7 @@ update_extension_flags( GLcontext *ctx )
 {
    /* Update flags */
    ctx->Extensions.HaveTextureEnvAdd = gl_extension_is_enabled(ctx, "GL_EXT_texture_env_add");
+   ctx->Extensions.HaveTextureEnvCombine = gl_extension_is_enabled(ctx, "GL_EXT_texture_env_combine");
    ctx->Extensions.HaveTextureLodBias = gl_extension_is_enabled(ctx, "GL_EXT_texture_lod_bias");
    ctx->Extensions.HaveHpOcclusionTest = gl_extension_is_enabled(ctx, "GL_HP_occlusion_test");
    ctx->Extensions.HaveTextureCubeMap = gl_extension_is_enabled(ctx, "GL_ARB_texture_cube_map");
index 32ce6005630e6dc0031106de980624d3326afe7e..64df9016dc945caadaf5b048e8bc8235d3d3e87a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: texstate.c,v 1.13 2000/05/23 20:10:50 brianp Exp $ */
+/* $Id: texstate.c,v 1.14 2000/06/27 21:42:13 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -71,64 +71,287 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexEnv");
 
    if (target==GL_TEXTURE_ENV) {
-
-      if (pname==GL_TEXTURE_ENV_MODE) {
-        GLenum mode = (GLenum) (GLint) *param;
-        switch (mode) {
-        case GL_ADD:
-           if (!ctx->Extensions.HaveTextureEnvAdd) {
-              gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(param)");
-              return;
-           }
-           /* FALL-THROUGH */
-        case GL_MODULATE:
-        case GL_BLEND:
-        case GL_DECAL:
-        case GL_REPLACE:
-           /* A small optimization for drivers */ 
-           if (texUnit->EnvMode == mode)
-              return;
-
-           if (MESA_VERBOSE & (VERBOSE_STATE|VERBOSE_TEXTURE))
-              fprintf(stderr, "glTexEnv: old mode %s, new mode %s\n",
-                      gl_lookup_enum_by_nr(texUnit->EnvMode),
-                      gl_lookup_enum_by_nr(mode));
-
-           texUnit->EnvMode = mode;
-           ctx->NewState |= NEW_TEXTURE_ENV;
-           break;
-        default:
-           gl_error( ctx, GL_INVALID_VALUE, "glTexEnv(param)" );
-           return;
-        }
-      }
-      else if (pname==GL_TEXTURE_ENV_COLOR) {
-        texUnit->EnvColor[0] = CLAMP( param[0], 0.0F, 1.0F );
-        texUnit->EnvColor[1] = CLAMP( param[1], 0.0F, 1.0F );
-        texUnit->EnvColor[2] = CLAMP( param[2], 0.0F, 1.0F );
-        texUnit->EnvColor[3] = CLAMP( param[3], 0.0F, 1.0F );
-      }
-      else {
-        gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" );
-        return;
+      switch (pname) {
+         case GL_TEXTURE_ENV_MODE:
+            {
+               GLenum mode = (GLenum) (GLint) *param;
+               switch (mode) {
+                  case GL_MODULATE:
+                  case GL_BLEND:
+                  case GL_DECAL:
+                  case GL_REPLACE:
+                  case GL_ADD:
+                  case GL_COMBINE_EXT:
+                     if (mode == GL_ADD &&
+                         !ctx->Extensions.HaveTextureEnvAdd) {
+                        gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(param)");
+                        return;
+                     }
+                     if (mode == GL_COMBINE_EXT &&
+                         !ctx->Extensions.HaveTextureEnvCombine) {
+                        gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(param)");
+                        return;
+                     }
+                     if (texUnit->EnvMode == mode)
+                        return;  /* no change */
+                     texUnit->EnvMode = mode;
+                     ctx->NewState |= NEW_TEXTURE_ENV;
+                     break;
+                  default:
+                     gl_error( ctx, GL_INVALID_VALUE, "glTexEnv(param)" );
+                     return;
+               }
+            }
+            break;
+         case GL_TEXTURE_ENV_COLOR:
+            texUnit->EnvColor[0] = CLAMP( param[0], 0.0F, 1.0F );
+            texUnit->EnvColor[1] = CLAMP( param[1], 0.0F, 1.0F );
+            texUnit->EnvColor[2] = CLAMP( param[2], 0.0F, 1.0F );
+            texUnit->EnvColor[3] = CLAMP( param[3], 0.0F, 1.0F );
+            break;
+         case GL_COMBINE_RGB_EXT:
+            if (ctx->Extensions.HaveTextureEnvCombine) {
+               GLenum mode = (GLenum) (GLint) *param;
+               switch (mode) {
+                  case GL_REPLACE:
+                  case GL_MODULATE:
+                  case GL_ADD:
+                  case GL_ADD_SIGNED_EXT:
+                  case GL_INTERPOLATE_EXT:
+                     if (texUnit->CombineModeRGB == mode)
+                        return;  /* no change */
+                     texUnit->CombineModeRGB = mode;
+                     ctx->NewState |= NEW_TEXTURE_ENV;
+                     break;
+                  default:
+                     gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+                     return;
+               }
+            }
+            else {
+               gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+               return;
+            }
+            break;
+         case GL_COMBINE_ALPHA_EXT:
+            if (ctx->Extensions.HaveTextureEnvCombine) {
+               GLenum mode = (GLenum) (GLint) *param;
+               switch (mode) {
+                  case GL_REPLACE:
+                  case GL_MODULATE:
+                  case GL_ADD:
+                  case GL_ADD_SIGNED_EXT:
+                  case GL_INTERPOLATE_EXT:
+                     if (texUnit->CombineModeA == mode)
+                        return;  /* no change */
+                     texUnit->CombineModeA = mode;
+                     ctx->NewState |= NEW_TEXTURE_ENV;
+                     break;
+                  default:
+                     gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+                     return;
+               }
+            }
+            else {
+               gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+               return;
+            }
+            break;
+         case GL_SOURCE0_RGB_EXT:
+         case GL_SOURCE1_RGB_EXT:
+         case GL_SOURCE2_RGB_EXT:
+            if (ctx->Extensions.HaveTextureEnvCombine) {
+               GLenum source = (GLenum) (GLint) *param;
+               GLuint s = pname - GL_SOURCE0_RGB_EXT;
+               switch (source) {
+                  case GL_TEXTURE:
+                  case GL_CONSTANT_EXT:
+                  case GL_PRIMARY_COLOR_EXT:
+                  case GL_PREVIOUS_EXT:
+                     if (texUnit->CombineSourceRGB[s] == source)
+                        return;  /* no change */
+                     texUnit->CombineSourceRGB[s] = source;
+                     ctx->NewState |= NEW_TEXTURE_ENV;
+                     break;
+                  default:
+                     gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+                     return;
+               }
+            }
+            else {
+               gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+               return;
+            }
+            break;
+         case GL_SOURCE0_ALPHA_EXT:
+         case GL_SOURCE1_ALPHA_EXT:
+         case GL_SOURCE2_ALPHA_EXT:
+            if (ctx->Extensions.HaveTextureEnvCombine) {
+               GLenum source = (GLenum) (GLint) *param;
+               GLuint s = pname - GL_SOURCE0_ALPHA_EXT;
+               switch (source) {
+                  case GL_TEXTURE:
+                  case GL_CONSTANT_EXT:
+                  case GL_PRIMARY_COLOR_EXT:
+                  case GL_PREVIOUS_EXT:
+                     if (texUnit->CombineSourceA[s] == source) return;
+                     texUnit->CombineSourceA[s] = source;
+                     ctx->NewState |= NEW_TEXTURE_ENV;
+                     break;
+                  default:
+                     gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+                     return;
+               }
+            }
+            else {
+               gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+               return;
+            }
+            break;
+         case GL_OPERAND0_RGB_EXT:
+         case GL_OPERAND1_RGB_EXT:
+            if (ctx->Extensions.HaveTextureEnvCombine) {
+               GLenum operand = (GLenum) (GLint) *param;
+               GLuint s = pname - GL_OPERAND0_RGB_EXT;
+               switch (operand) {
+                  case GL_SRC_COLOR:
+                  case GL_ONE_MINUS_SRC_COLOR:
+                     texUnit->CombineOperandRGB[s] = operand;
+                     ctx->NewState |= NEW_TEXTURE_ENV;
+                     break;
+                  case GL_SRC_ALPHA:
+                  case GL_ONE_MINUS_SRC_ALPHA:
+                     texUnit->CombineOperandA[s] = operand;
+                     ctx->NewState |= NEW_TEXTURE_ENV;
+                     break;
+                  default:
+                     gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+                     return;
+               }
+            }
+            else {
+               gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+               return;
+            }
+            break;
+         case GL_OPERAND0_ALPHA_EXT:
+         case GL_OPERAND1_ALPHA_EXT:
+            if (ctx->Extensions.HaveTextureEnvCombine) {
+               GLenum operand = (GLenum) (GLint) *param;
+               switch (operand) {
+                  case GL_SRC_ALPHA:
+                  case GL_ONE_MINUS_SRC_ALPHA:
+                     texUnit->CombineOperandA[pname-GL_OPERAND0_ALPHA_EXT]
+                        = operand;
+                     ctx->NewState |= NEW_TEXTURE_ENV;
+                     break;
+                  default:
+                     gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+                     return;
+               }
+            }
+            else {
+               gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+               return;
+            }
+            break;
+         case GL_OPERAND2_RGB_EXT:
+            if (ctx->Extensions.HaveTextureEnvCombine) {
+               if ((GLenum) (GLint) *param == GL_SRC_ALPHA) {
+                  texUnit->CombineOperandRGB[2] = (GLenum) (GLint) *param;
+                  ctx->NewState |= NEW_TEXTURE_ENV;
+               }
+               else {
+                  gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+                  return;
+               }
+            }
+            else {
+               gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+               return;
+            }
+            break;
+         case GL_OPERAND2_ALPHA_EXT:
+            if (ctx->Extensions.HaveTextureEnvCombine) {
+               if ((GLenum) (GLint) *param == GL_SRC_ALPHA) {
+                  texUnit->CombineOperandA[2] = (GLenum) (GLint) *param;
+                  ctx->NewState |= NEW_TEXTURE_ENV;
+               }
+               else {
+                  gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+                  return;
+               }
+            }
+            else {
+               gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+               return;
+            }
+            break;
+         case GL_RGB_SCALE_EXT:
+            if (ctx->Extensions.HaveTextureEnvCombine) {
+               if (*param == 1.0) {
+                  texUnit->CombineScaleShiftRGB = 0;
+                  ctx->NewState |= NEW_TEXTURE_ENV;
+               }
+               else if (*param == 2.0) {
+                  texUnit->CombineScaleShiftRGB = 1;
+                  ctx->NewState |= NEW_TEXTURE_ENV;
+               }
+               else if (*param == 4.0) {
+                  texUnit->CombineScaleShiftRGB = 2;
+                  ctx->NewState |= NEW_TEXTURE_ENV;
+               }
+               else {
+                  gl_error( ctx, GL_INVALID_VALUE, "glTexEnv(param)" );
+                  return;
+               }
+            }
+            else {
+               gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+               return;
+            }
+            break;
+         case GL_ALPHA_SCALE:
+            if (ctx->Extensions.HaveTextureEnvCombine) {
+               if (*param == 1.0) {
+                  texUnit->CombineScaleShiftA = 0;
+                  ctx->NewState |= NEW_TEXTURE_ENV;
+               }
+               else if (*param == 2.0) {
+                  texUnit->CombineScaleShiftA = 1;
+                  ctx->NewState |= NEW_TEXTURE_ENV;
+               }
+               else if (*param == 4.0) {
+                  texUnit->CombineScaleShiftA = 2;
+                  ctx->NewState |= NEW_TEXTURE_ENV;
+               }
+               else {
+                  gl_error( ctx, GL_INVALID_VALUE, "glTexEnv(param)" );
+                  return;
+               }
+            }
+            else {
+               gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+               return;
+            }
+            break;
+         default:
+            gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" );
+            return;
       }
-
    }
    else if (target==GL_TEXTURE_FILTER_CONTROL_EXT) {
-
       if (!ctx->Extensions.HaveTextureLodBias) {
         gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
         return;
       }
-
-      if (pname==GL_TEXTURE_LOD_BIAS_EXT) {
+      if (pname == GL_TEXTURE_LOD_BIAS_EXT) {
         texUnit->LodBias = param[0];
       }
       else {
         gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" );
         return;
       }
-
    }
    else {
       gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(target)" );
@@ -184,7 +407,7 @@ void
 _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+   const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
 
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexEnvfv");
 
@@ -192,6 +415,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
       gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" );
       return;
    }
+
    switch (pname) {
       case GL_TEXTURE_ENV_MODE:
          *params = ENUM_TO_FLOAT(texUnit->EnvMode);
@@ -199,6 +423,34 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
       case GL_TEXTURE_ENV_COLOR:
         COPY_4FV( params, texUnit->EnvColor );
         break;
+      case GL_RGB_SCALE_EXT:
+         if (ctx->Extensions.HaveTextureEnvCombine) {
+            if (texUnit->CombineScaleShiftRGB == 0)
+               *params = 1.0;
+            else if (texUnit->CombineScaleShiftRGB == 1)
+               *params = 2.0;
+            else
+               *params = 4.0;
+         }
+         else {
+            gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+            return;
+         }
+         break;
+      case GL_ALPHA_SCALE:
+         if (ctx->Extensions.HaveTextureEnvCombine) {
+            if (texUnit->CombineScaleShiftA == 0)
+               *params = 1.0;
+            else if (texUnit->CombineScaleShiftA == 1)
+               *params = 2.0;
+            else
+               *params = 4.0;
+         }
+         else {
+            gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+            return;
+         }
+         break;
       default:
          gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" );
    }
@@ -209,14 +461,15 @@ void
 _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
 {
    GET_CURRENT_CONTEXT(ctx);
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+   const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
 
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexEnviv");
 
-   if (target!=GL_TEXTURE_ENV) {
+   if (target != GL_TEXTURE_ENV) {
       gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" );
       return;
    }
+
    switch (pname) {
       case GL_TEXTURE_ENV_MODE:
          *params = (GLint) texUnit->EnvMode;
@@ -226,6 +479,118 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
         params[1] = FLOAT_TO_INT( texUnit->EnvColor[1] );
         params[2] = FLOAT_TO_INT( texUnit->EnvColor[2] );
         params[3] = FLOAT_TO_INT( texUnit->EnvColor[3] );
+         break;
+      case GL_COMBINE_RGB_EXT:
+         if (ctx->Extensions.HaveTextureEnvCombine) {
+            *params = (GLint) texUnit->CombineModeRGB;
+         }
+         else {
+            gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+         }
+         break;
+      case GL_COMBINE_ALPHA_EXT:
+         if (ctx->Extensions.HaveTextureEnvCombine) {
+            *params = (GLint) texUnit->CombineModeA;
+         }
+         else {
+            gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+         }
+         break;
+      case GL_SOURCE0_RGB_EXT:
+         if (ctx->Extensions.HaveTextureEnvCombine) {
+            *params = (GLint) texUnit->CombineSourceRGB[0];
+         }
+         else {
+            gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+         }
+         break;
+      case GL_SOURCE1_RGB_EXT:
+         if (ctx->Extensions.HaveTextureEnvCombine) {
+            *params = (GLint) texUnit->CombineSourceRGB[1];
+         }
+         else {
+            gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+         }
+         break;
+      case GL_SOURCE2_RGB_EXT:
+         if (ctx->Extensions.HaveTextureEnvCombine) {
+            *params = (GLint) texUnit->CombineSourceRGB[2];
+         }
+         else {
+            gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+         }
+         break;
+      case GL_SOURCE0_ALPHA_EXT:
+         if (ctx->Extensions.HaveTextureEnvCombine) {
+            *params = (GLint) texUnit->CombineSourceA[0];
+         }
+         else {
+            gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+         }
+         break;
+      case GL_SOURCE1_ALPHA_EXT:
+         if (ctx->Extensions.HaveTextureEnvCombine) {
+            *params = (GLint) texUnit->CombineSourceA[1];
+         }
+         else {
+            gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+         }
+         break;
+      case GL_SOURCE2_ALPHA_EXT:
+         if (ctx->Extensions.HaveTextureEnvCombine) {
+            *params = (GLint) texUnit->CombineSourceA[2];
+         }
+         else {
+            gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+         }
+         break;
+      case GL_OPERAND0_RGB_EXT:
+         if (ctx->Extensions.HaveTextureEnvCombine) {
+            *params = (GLint) texUnit->CombineOperandRGB[0];
+         }
+         else {
+            gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+         }
+         break;
+      case GL_OPERAND1_RGB_EXT:
+         if (ctx->Extensions.HaveTextureEnvCombine) {
+            *params = (GLint) texUnit->CombineOperandRGB[1];
+         }
+         else {
+            gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+         }
+         break;
+      case GL_OPERAND2_RGB_EXT:
+         if (ctx->Extensions.HaveTextureEnvCombine) {
+            *params = (GLint) texUnit->CombineOperandRGB[2];
+         }
+         else {
+            gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+         }
+         break;
+      case GL_OPERAND0_ALPHA_EXT:
+         if (ctx->Extensions.HaveTextureEnvCombine) {
+            *params = (GLint) texUnit->CombineOperandA[0];
+         }
+         else {
+            gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+         }
+         break;
+      case GL_OPERAND1_ALPHA_EXT:
+         if (ctx->Extensions.HaveTextureEnvCombine) {
+            *params = (GLint) texUnit->CombineOperandA[1];
+         }
+         else {
+            gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+         }
+         break;
+      case GL_OPERAND2_ALPHA_EXT:
+         if (ctx->Extensions.HaveTextureEnvCombine) {
+            *params = (GLint) texUnit->CombineOperandA[2];
+         }
+         else {
+            gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+         }
         break;
       default:
          gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)" );