diff options
-rw-r--r-- | src/mesa/main/teximage.c | 66 | ||||
-rw-r--r-- | src/mesa/main/teximage.h | 5 | ||||
-rw-r--r-- | src/mesa/main/texstore.c | 28 |
3 files changed, 48 insertions, 51 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index e33a3986756..74b526e0f3d 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1,4 +1,4 @@ -/* $Id: teximage.c,v 1.121 2002/10/18 13:24:08 brianp Exp $ */ +/* $Id: teximage.c,v 1.122 2002/10/18 18:03:04 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -583,6 +583,41 @@ _mesa_select_tex_image(GLcontext *ctx, const struct gl_texture_unit *texUnit, } +/* + * Return the maximum number of allows mipmap levels for the given + * texture target. + */ +GLint +_mesa_max_texture_levels(GLcontext *ctx, GLenum target) +{ + switch (target) { + case GL_TEXTURE_1D: + case GL_PROXY_TEXTURE_1D: + case GL_TEXTURE_2D: + case GL_PROXY_TEXTURE_2D: + return ctx->Const.MaxTextureLevels; + case GL_TEXTURE_3D: + case GL_PROXY_TEXTURE_3D: + return ctx->Const.Max3DTextureLevels; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: + case GL_PROXY_TEXTURE_CUBE_MAP_ARB: + return ctx->Const.MaxCubeTextureLevels; + break; + case GL_TEXTURE_RECTANGLE_NV: + case GL_PROXY_TEXTURE_RECTANGLE_NV: + return 1; + break; + default: + return 0; /* bad target */ + } +} + + #if 000 /* not used anymore */ /* @@ -1455,20 +1490,8 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, return; } - if (target == GL_TEXTURE_1D || target == GL_TEXTURE_2D) { - maxLevels = ctx->Const.MaxTextureLevels; - } - else if (target == GL_TEXTURE_3D) { - maxLevels = ctx->Const.Max3DTextureLevels; - } - else if (target == GL_TEXTURE_RECTANGLE_NV) { - maxLevels = 1; - } - else { - maxLevels = ctx->Const.MaxCubeTextureLevels; - } - - ASSERT(maxLevels > 0); + maxLevels = _mesa_max_texture_levels(ctx, target); + ASSERT(maxLevels > 0); /* 0 indicates bad target, caught above */ if (level < 0 || level >= maxLevels) { _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexImage(level)" ); @@ -2887,17 +2910,8 @@ _mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img) return; } - if (target == GL_TEXTURE_1D || target == GL_TEXTURE_2D) { - maxLevels = ctx->Const.MaxTextureLevels; - } - else if (target == GL_TEXTURE_3D) { - maxLevels = ctx->Const.Max3DTextureLevels; - } - else { - maxLevels = ctx->Const.MaxCubeTextureLevels; - } - - ASSERT(maxLevels > 0); + maxLevels = _mesa_max_texture_levels(ctx, target); + ASSERT(maxLevels > 0); /* 0 indicates bad target, caught above */ if (level < 0 || level >= maxLevels) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetCompressedTexImageARB(level)"); diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h index 03b052c414e..8cbc0d66152 100644 --- a/src/mesa/main/teximage.h +++ b/src/mesa/main/teximage.h @@ -1,4 +1,4 @@ -/* $Id: teximage.h,v 1.21 2002/06/15 03:03:09 brianp Exp $ */ +/* $Id: teximage.h,v 1.22 2002/10/18 18:03:07 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -70,6 +70,9 @@ _mesa_select_tex_image(GLcontext *ctx, const struct gl_texture_unit *texUnit, GLenum target, GLint level); +extern GLint +_mesa_max_texture_levels(GLcontext *ctx, GLenum target); + /*** API entry point functions ***/ diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 91bd6357549..2be6e476458 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -1,4 +1,4 @@ -/* $Id: texstore.c,v 1.43 2002/10/18 17:41:45 brianp Exp $ */ +/* $Id: texstore.c,v 1.44 2002/10/18 18:03:08 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1897,34 +1897,14 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target, const struct gl_texture_format *convertFormat; const GLubyte *srcData; GLubyte *dstData; - GLint level; - GLint maxLevels = 0; + GLint level, maxLevels; ASSERT(texObj); srcImage = texObj->Image[texObj->BaseLevel]; ASSERT(srcImage); - switch (texObj->Target) { - case GL_TEXTURE_1D: - maxLevels = ctx->Const.MaxTextureLevels; - break; - case GL_TEXTURE_2D: - maxLevels = ctx->Const.MaxTextureLevels; - break; - case GL_TEXTURE_3D: - maxLevels = ctx->Const.Max3DTextureLevels; - break; - case GL_TEXTURE_CUBE_MAP_ARB: - maxLevels = ctx->Const.MaxCubeTextureLevels; - break; - case GL_TEXTURE_RECTANGLE_NV: - maxLevels = 1; - break; - default: - _mesa_problem(ctx, - "Bad texture object dimension in _mesa_generate_mipmaps"); - return; - } + maxLevels = _mesa_max_texture_levels(ctx, texObj->Target); + ASSERT(maxLevels > 0); /* bad target */ /* Find convertFormat - the format that do_row() will process */ if (srcImage->IsCompressed) { |