Added OpenGL 1.4's per-texture LOD bias.
authorBrian Paul <brian.paul@tungstengraphics.com>
Thu, 28 Aug 2003 03:04:41 +0000 (03:04 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Thu, 28 Aug 2003 03:04:41 +0000 (03:04 +0000)
src/mesa/main/extensions.c
src/mesa/main/get.c
src/mesa/main/mtypes.h
src/mesa/main/texobj.c
src/mesa/main/texstate.c
src/mesa/swrast/s_texture.c

index 9122ff5a7aad0d5c8861ccc3453228b9341ac293..886311e0f1c16189f90cc368e08f7ddc7f1a4f0e 100644 (file)
@@ -290,6 +290,7 @@ _mesa_enable_1_4_extensions(GLcontext *ctx)
    ctx->Extensions.EXT_point_parameters = GL_TRUE;
    ctx->Extensions.EXT_secondary_color = GL_TRUE;
    ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
+   ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
    ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
 }
 
index 92d6a1d3a121c0e3aba97b0284155e916ba93126..29cc14636dd6fc3cbdb9b0f3f5524f43e323fdb7 100644 (file)
@@ -6428,6 +6428,7 @@ _mesa_GetString( GLenum name )
                    ctx->Extensions.EXT_point_parameters && /*aka ARB*/
                    ctx->Extensions.EXT_secondary_color &&
                    ctx->Extensions.EXT_stencil_wrap &&
+                   ctx->Extensions.EXT_texture_lod_bias &&
                    ctx->Extensions.SGIS_generate_mipmap) {
                   if (ctx->Extensions.ARB_occlusion_query &&
                       ctx->Extensions.ARB_point_sprite &&
index 90fdd3b83c441c2d9fbaf3662828f8e999c2ab63..5497aac838098bda8b7ddc701981369bf277e01e 100644 (file)
@@ -1073,6 +1073,7 @@ struct gl_texture_object {
    GLenum MagFilter;           /**< magnification filter */
    GLfloat MinLod;             /**< min lambda, OpenGL 1.2 */
    GLfloat MaxLod;             /**< max lambda, OpenGL 1.2 */
+   GLfloat LodBias;            /**< OpenGL 1.4 */
    GLint BaseLevel;            /**< min mipmap level, OpenGL 1.2 */
    GLint MaxLevel;             /**< max mipmap level, OpenGL 1.2 */
    GLfloat MaxAnisotropy;      /**< GL_EXT_texture_filter_anisotropic */
index ff0a0535f118216ab1350c66f5011d90f1a64b4b..6edb7e65655afbfb1e8b390d9efbf76927acd383 100644 (file)
@@ -114,6 +114,7 @@ _mesa_initialize_texture_object( struct gl_texture_object *obj,
    obj->MagFilter = GL_LINEAR;
    obj->MinLod = -1000.0;
    obj->MaxLod = 1000.0;
+   obj->LodBias = 0.0;
    obj->BaseLevel = 0;
    obj->MaxLevel = 1000;
    obj->MaxAnisotropy = 1.0;
@@ -242,6 +243,7 @@ _mesa_copy_texture_object( struct gl_texture_object *dest,
    dest->MagFilter = src->MagFilter;
    dest->MinLod = src->MinLod;
    dest->MaxLod = src->MaxLod;
+   dest->LodBias = src->LodBias;
    dest->BaseLevel = src->BaseLevel;
    dest->MaxLevel = src->MaxLevel;
    dest->MaxAnisotropy = src->MaxAnisotropy;
index 8110772d3c8fee7674cf856be2ba79444142f011..2c1d155f52ece56e98515e316b81353a0ce42f81 100644 (file)
@@ -1399,6 +1399,14 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
             return;
          }
          break;
+      case GL_TEXTURE_LOD_BIAS:
+         /* NOTE: this is really part of OpenGL 1.4, not EXT_texture_lod_bias*/
+         if (ctx->Extensions.EXT_texture_lod_bias) {
+            texObj->LodBias = CLAMP(params[0],
+                                    -ctx->Const.MaxTextureLodBias,
+                                    ctx->Const.MaxTextureLodBias);
+         }
+         break;
 
       default:
          _mesa_error(ctx, GL_INVALID_ENUM,
@@ -1775,6 +1783,12 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
             return;
          }
          break;
+      case GL_TEXTURE_LOD_BIAS:
+         if (ctx->Extensions.EXT_texture_lod_bias) {
+            *params = obj->LodBias;
+            break;
+         }
+         break;
       default:
          ; /* silence warnings */
    }
@@ -1801,6 +1815,12 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
    switch (pname) {
       case GL_TEXTURE_MAG_FILTER:
          *params = (GLint) obj->MagFilter;
+      case GL_TEXTURE_LOD_BIAS:
+         if (ctx->Extensions.EXT_texture_lod_bias) {
+            *params = (GLint) obj->LodBias;
+            break;
+         }
+         break;
          return;
       case GL_TEXTURE_MIN_FILTER:
          *params = (GLint) obj->MinFilter;
index 172401f594b4bff037c674ed56b77a900871ae12..b9e08148ecfb251559fb8009f2834564c62f1996 100644 (file)
@@ -4198,11 +4198,11 @@ _swrast_texture_span( GLcontext *ctx, struct sw_span *span )
 
          /* adjust texture lod (lambda) */
          if (span->arrayMask & SPAN_LAMBDA) {
-            if (texUnit->LodBias != 0.0F) {
+            if (texUnit->LodBias + curObj->LodBias != 0.0F) {
                /* apply LOD bias, but don't clamp yet */
                GLuint i;
                for (i = 0; i < span->end; i++) {
-                  lambda[i] += texUnit->LodBias;
+                  lambda[i] += (texUnit->LodBias + curObj->LodBias);
                }
             }