summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/teximage.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2002-10-18 18:03:04 +0000
committerBrian Paul <[email protected]>2002-10-18 18:03:04 +0000
commitef31f60b12abc2109568fb8d9a2aaa70ec5c71cc (patch)
tree7f35cbee92127a0e1b06b9a95656bf8cfcb46550 /src/mesa/main/teximage.c
parent53d30c56eb1a0865a6a88cf05c4c74673d41b2a4 (diff)
new _mesa_max_texture_levels() helper function - not used everywhere yet
Diffstat (limited to 'src/mesa/main/teximage.c')
-rw-r--r--src/mesa/main/teximage.c66
1 files changed, 40 insertions, 26 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)");