In gl_texture_image replace IntFormat with InternalFormat and Format with
[mesa.git] / src / mesa / main / texstate.c
index a425de42168148cf48efbee261355494c0bd7943..3cc343d287e63d337c194d98d5155e7409d3d54a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.3
+ * Version:  6.5
  *
  * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
  *
@@ -544,8 +544,7 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
         }
         break;
       case GL_OPERAND2_RGB:
-        if (ctx->Extensions.EXT_texture_env_combine ||
-             ctx->Extensions.ARB_texture_env_combine) {
+        if (ctx->Extensions.ARB_texture_env_combine) {
            const GLenum operand = (GLenum) (GLint) *param;
            if (texUnit->Combine.OperandRGB[2] == operand)
               return;
@@ -562,14 +561,24 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
               return;
            }
         }
+        else if (ctx->Extensions.EXT_texture_env_combine) {
+           const GLenum operand = (GLenum) (GLint) *param;
+           if (texUnit->Combine.OperandRGB[2] == operand)
+              return;
+           /* operand must be GL_SRC_ALPHA which is the initial value - thus
+              don't need to actually compare the operand to the possible value */
+           else {
+               TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", operand);
+              return;
+           }
+        }
         else {
             TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
            return;
         }
         break;
       case GL_OPERAND2_ALPHA:
-        if (ctx->Extensions.EXT_texture_env_combine ||
-             ctx->Extensions.ARB_texture_env_combine) {
+        if (ctx->Extensions.ARB_texture_env_combine) {
            const GLenum operand = (GLenum) (GLint) *param;
            if (texUnit->Combine.OperandA[2] == operand)
               return;
@@ -584,6 +593,17 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
               return;
            }
         }
+        else if (ctx->Extensions.EXT_texture_env_combine) {
+           const GLenum operand = (GLenum) (GLint) *param;
+           if (texUnit->Combine.OperandA[2] == operand)
+              return;
+           /* operand must be GL_SRC_ALPHA which is the initial value - thus
+              don't need to actually compare the operand to the possible value */
+           else {
+               TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", operand);
+              return;
+           }
+        }
         else {
             TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
            return;
@@ -1697,38 +1717,39 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
          *params = img->Depth;
          return;
       case GL_TEXTURE_INTERNAL_FORMAT:
-         *params = img->IntFormat;
+         *params = img->InternalFormat;
          return;
       case GL_TEXTURE_BORDER:
          *params = img->Border;
          return;
       case GL_TEXTURE_RED_SIZE:
-         if (img->Format == GL_RGB || img->Format == GL_RGBA)
+         if (img->_BaseFormat == GL_RGB || img->_BaseFormat == GL_RGBA)
             *params = img->TexFormat->RedBits;
          else
             *params = 0;
          return;
       case GL_TEXTURE_GREEN_SIZE:
-         if (img->Format == GL_RGB || img->Format == GL_RGBA)
+         if (img->_BaseFormat == GL_RGB || img->_BaseFormat == GL_RGBA)
             *params = img->TexFormat->GreenBits;
          else
             *params = 0;
          return;
       case GL_TEXTURE_BLUE_SIZE:
-         if (img->Format == GL_RGB || img->Format == GL_RGBA)
+         if (img->_BaseFormat == GL_RGB || img->_BaseFormat == GL_RGBA)
             *params = img->TexFormat->BlueBits;
          else
             *params = 0;
          return;
       case GL_TEXTURE_ALPHA_SIZE:
-         if (img->Format == GL_ALPHA || img->Format == GL_LUMINANCE_ALPHA ||
-             img->Format == GL_RGBA)
+         if (img->_BaseFormat == GL_ALPHA ||
+             img->_BaseFormat == GL_LUMINANCE_ALPHA ||
+             img->_BaseFormat == GL_RGBA)
             *params = img->TexFormat->AlphaBits;
          else
             *params = 0;
          return;
       case GL_TEXTURE_INTENSITY_SIZE:
-         if (img->Format != GL_INTENSITY)
+         if (img->_BaseFormat != GL_INTENSITY)
             *params = 0;
          else if (img->TexFormat->IntensityBits > 0)
             *params = img->TexFormat->IntensityBits;
@@ -1736,8 +1757,8 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
             *params = MIN2(img->TexFormat->RedBits, img->TexFormat->GreenBits);
          return;
       case GL_TEXTURE_LUMINANCE_SIZE:
-         if (img->Format != GL_LUMINANCE &&
-             img->Format != GL_LUMINANCE_ALPHA)
+         if (img->_BaseFormat != GL_LUMINANCE &&
+             img->_BaseFormat != GL_LUMINANCE_ALPHA)
             *params = 0;
          else if (img->TexFormat->LuminanceBits > 0)
             *params = img->TexFormat->LuminanceBits;
@@ -1745,21 +1766,28 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
             *params = MIN2(img->TexFormat->RedBits, img->TexFormat->GreenBits);
          return;
       case GL_TEXTURE_INDEX_SIZE_EXT:
-         if (img->Format == GL_COLOR_INDEX)
+         if (img->_BaseFormat == GL_COLOR_INDEX)
             *params = img->TexFormat->IndexBits;
          else
             *params = 0;
          return;
-      case GL_DEPTH_BITS:
-         /* XXX this isn't in the GL_SGIX_depth_texture spec
-          * but seems appropriate.
-          */
-         if (ctx->Extensions.SGIX_depth_texture)
+      case GL_TEXTURE_DEPTH_SIZE_ARB:
+         if (ctx->Extensions.SGIX_depth_texture ||
+             ctx->Extensions.ARB_depth_texture)
             *params = img->TexFormat->DepthBits;
          else
             _mesa_error(ctx, GL_INVALID_ENUM,
                         "glGetTexLevelParameter[if]v(pname)");
          return;
+      case GL_TEXTURE_STENCIL_SIZE_EXT:
+         if (ctx->Extensions.EXT_packed_depth_stencil) {
+            *params = img->TexFormat->StencilBits;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM,
+                        "glGetTexLevelParameter[if]v(pname)");
+         }
+         return;
 
       /* GL_ARB_texture_compression */
       case GL_TEXTURE_COMPRESSED_IMAGE_SIZE:
@@ -1849,6 +1877,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
                         "glGetTexLevelParameter[if]v(pname)");
          }
          return;
+
       default:
          _mesa_error(ctx, GL_INVALID_ENUM,
                      "glGetTexLevelParameter[if]v(pname)");
@@ -2137,7 +2166,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
       case GL_S:
          if (pname==GL_TEXTURE_GEN_MODE) {
            GLenum mode = (GLenum) (GLint) *params;
-           GLuint bits;
+           GLbitfield bits;
            switch (mode) {
            case GL_OBJECT_LINEAR:
               bits = TEXGEN_OBJ_LINEAR;
@@ -2194,7 +2223,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
       case GL_T:
          if (pname==GL_TEXTURE_GEN_MODE) {
            GLenum mode = (GLenum) (GLint) *params;
-           GLuint bitt;
+           GLbitfield bitt;
            switch (mode) {
                case GL_OBJECT_LINEAR:
                   bitt = TEXGEN_OBJ_LINEAR;
@@ -2250,7 +2279,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
       case GL_R:
          if (pname==GL_TEXTURE_GEN_MODE) {
            GLenum mode = (GLenum) (GLint) *params;
-           GLuint bitr;
+           GLbitfield bitr;
            switch (mode) {
            case GL_OBJECT_LINEAR:
               bitr = TEXGEN_OBJ_LINEAR;
@@ -2303,7 +2332,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
       case GL_Q:
          if (pname==GL_TEXTURE_GEN_MODE) {
            GLenum mode = (GLenum) (GLint) *params;
-           GLuint bitq;
+           GLbitfield bitq;
            switch (mode) {
            case GL_OBJECT_LINEAR:
               bitq = TEXGEN_OBJ_LINEAR;
@@ -2919,7 +2948,7 @@ update_texture_state( GLcontext *ctx )
     */
    for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
       struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-      GLuint enableBits;
+      GLbitfield enableBits;
 
       texUnit->_Current = NULL;
       texUnit->_ReallyEnabled = 0;
@@ -3005,11 +3034,12 @@ update_texture_state( GLcontext *ctx )
         texUnit->_CurrentCombine = & texUnit->Combine;
       }
       else {
-         GLenum format = texUnit->_Current->Image[0][0]->Format;
+         GLenum format = texUnit->_Current->Image[0][0]->_BaseFormat;
          if (format == GL_COLOR_INDEX) {
             format = GL_RGBA;  /* a bit of a hack */
          }
-         else if (format == GL_DEPTH_COMPONENT) {
+         else if (format == GL_DEPTH_COMPONENT
+                  || format == GL_DEPTH_STENCIL_EXT) {
             format = texUnit->_Current->DepthMode;
          }
         calculate_derived_texenv(&texUnit->_EnvMode, texUnit->EnvMode, format);