-/* $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
}
+/*
+ * 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 */
/*
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)" );
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)");
-/* $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
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) {