summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2000-05-23 15:17:12 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2000-05-23 15:17:12 +0000
commitfc4b44399a07a7a7559f20ceab8a791209b4d875 (patch)
tree1b3e06659b40d45fc3c516cbb449434552fdb7a7 /src
parentdf54463363729a25a7c11739d3b09f5a1e3083ef (diff)
more work on GL_ARB_texture_cube_map
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/enable.c60
-rw-r--r--src/mesa/main/get.c28
-rw-r--r--src/mesa/main/teximage.c189
-rw-r--r--src/mesa/main/teximage.h7
-rw-r--r--src/mesa/main/texobj.c43
-rw-r--r--src/mesa/main/texstate.c81
6 files changed, 274 insertions, 134 deletions
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index b4df44de34..0fa408f764 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -1,4 +1,4 @@
-/* $Id: enable.c,v 1.20 2000/05/22 16:33:21 brianp Exp $ */
+/* $Id: enable.c,v 1.21 2000/05/23 15:17:12 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -508,23 +508,30 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
/* GL_ARB_texture_cube_map */
case GL_TEXTURE_CUBE_MAP_ARB:
-#if 0
- if (ctx->Visual->RGBAflag) {
- const GLuint curr = ctx->Texture.CurrentUnit;
- const GLuint flag = TEXTURE0_CUBE << (curr * 4);
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
- ctx->NewState |= NEW_TEXTURE_ENABLE;
- if (state) {
- texUnit->Enabled |= TEXTURE0_2D;
- ctx->Enabled |= flag;
- }
- else {
- texUnit->Enabled &= ~TEXTURE0_2D;
- ctx->Enabled &= ~flag;
+ if (ctx->Extensions.HaveTextureCubeMap) {
+ if (ctx->Visual->RGBAflag) {
+ const GLuint curr = ctx->Texture.CurrentUnit;
+ const GLuint flag = TEXTURE0_CUBE << (curr * 4);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
+ ctx->NewState |= NEW_TEXTURE_ENABLE;
+ if (state) {
+ texUnit->Enabled |= TEXTURE0_CUBE;
+ ctx->Enabled |= flag;
+ }
+ else {
+ texUnit->Enabled &= ~TEXTURE0_CUBE;
+ ctx->Enabled &= ~flag;
+ }
}
}
+ else {
+ if (state)
+ gl_error(ctx, GL_INVALID_ENUM, "glEnable");
+ else
+ gl_error(ctx, GL_INVALID_ENUM, "glDisable");
+ return;
+ }
break;
-#endif
default:
if (state) {
@@ -760,23 +767,14 @@ _mesa_IsEnabled( GLenum cap )
/* GL_ARB_texture_cube_map */
case GL_TEXTURE_CUBE_MAP_ARB:
-#if 0
- if (ctx->Visual->RGBAflag) {
- const GLuint curr = ctx->Texture.CurrentUnit;
- const GLuint flag = TEXTURE0_CUBE << (curr * 4);
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
- ctx->NewState |= NEW_TEXTURE_ENABLE;
- if (state) {
- texUnit->Enabled |= TEXTURE0_2D;
- ctx->Enabled |= flag;
- }
- else {
- texUnit->Enabled &= ~TEXTURE0_2D;
- ctx->Enabled &= ~flag;
- }
+ if (ctx->Extensions.HaveTextureCubeMap) {
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ return (texUnit->Enabled & TEXTURE0_CUBE) ? GL_TRUE : GL_FALSE;
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glIsEnabled");
+ return GL_FALSE;
}
- break;
-#endif
default:
gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index e6e4a59717..8302b3459e 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1,4 +1,4 @@
-/* $Id: get.c,v 1.26 2000/05/22 16:33:21 brianp Exp $ */
+/* $Id: get.c,v 1.27 2000/05/23 15:17:13 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -963,7 +963,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
return;
case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
if (ctx->Extensions.HaveTextureCubeMap)
- *params = INT_TO_BOOL(textureUnit->CurrentPosX->Name);
+ *params = INT_TO_BOOL(textureUnit->CurrentCubeMap->Name);
else
gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
return;
@@ -2077,19 +2077,19 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
if (ctx->Extensions.HaveTextureCubeMap)
*params = (GLdouble) _mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB);
else
- gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+ gl_error(ctx, GL_INVALID_ENUM, "glGetDoublev");
return;
case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
if (ctx->Extensions.HaveTextureCubeMap)
- *params = (GLdouble) textureUnit->CurrentPosX->Name;
+ *params = (GLdouble) textureUnit->CurrentCubeMap->Name;
else
- gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+ gl_error(ctx, GL_INVALID_ENUM, "glGetDoublev");
return;
case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
if (ctx->Extensions.HaveTextureCubeMap)
*params = (GLdouble) ctx->Const.MaxCubeTextureSize;
else
- gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+ gl_error(ctx, GL_INVALID_ENUM, "glGetDoublev");
return;
/* GL_PGI_misc_hints */
@@ -3194,19 +3194,19 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
if (ctx->Extensions.HaveTextureCubeMap)
*params = (GLfloat) _mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB);
else
- gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+ gl_error(ctx, GL_INVALID_ENUM, "glGetFloatv");
return;
case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
if (ctx->Extensions.HaveTextureCubeMap)
- *params = (GLfloat) textureUnit->CurrentPosX->Name;
+ *params = (GLfloat) textureUnit->CurrentCubeMap->Name;
else
- gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+ gl_error(ctx, GL_INVALID_ENUM, "glGetFloatv");
return;
case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
if (ctx->Extensions.HaveTextureCubeMap)
*params = (GLfloat) ctx->Const.MaxCubeTextureSize;
else
- gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+ gl_error(ctx, GL_INVALID_ENUM, "glGetFloatv");
return;
/* GL_PGI_misc_hints */
@@ -4285,19 +4285,19 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
if (ctx->Extensions.HaveTextureCubeMap)
*params = (GLint) _mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB);
else
- gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+ gl_error(ctx, GL_INVALID_ENUM, "glGetIntegerv");
return;
case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
if (ctx->Extensions.HaveTextureCubeMap)
- *params = textureUnit->CurrentPosX->Name;
+ *params = textureUnit->CurrentCubeMap->Name;
else
- gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+ gl_error(ctx, GL_INVALID_ENUM, "glGetIntegerv");
return;
case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
if (ctx->Extensions.HaveTextureCubeMap)
*params = ctx->Const.MaxCubeTextureSize;
else
- gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+ gl_error(ctx, GL_INVALID_ENUM, "glGetIntegerv");
return;
/* GL_PGI_misc_hints */
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 2f3c0f12c8..74be5546f8 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -400,17 +400,12 @@ select_tex_object(struct gl_texture_unit *unit, GLenum target)
case GL_TEXTURE_3D:
return unit->CurrentD[3];
case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
- return unit->CurrentPosX;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
- return unit->CurrentNegX;
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
- return unit->CurrentPosY;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
- return unit->CurrentNegY;
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
- return unit->CurrentPosZ;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
- return unit->CurrentNegZ;
+ return unit->CurrentCubeMap;
default:
gl_problem(NULL, "bad target in select_tex_object()");
return NULL;
@@ -418,6 +413,42 @@ select_tex_object(struct gl_texture_unit *unit, GLenum target)
}
+static void
+set_tex_image(struct gl_texture_object *tObj,
+ GLenum target, GLint level,
+ struct gl_texture_image *texImage)
+{
+ ASSERT(tObj);
+ ASSERT(texImage);
+ switch (target) {
+ case GL_TEXTURE_2D:
+ tObj->Image[level] = texImage;
+ return;
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
+ tObj->PosX[level] = texImage;
+ return;
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
+ tObj->NegX[level] = texImage;
+ return;
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
+ tObj->PosY[level] = texImage;
+ return;
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
+ tObj->NegY[level] = texImage;
+ return;
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
+ tObj->PosZ[level] = texImage;
+ return;
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
+ tObj->NegZ[level] = texImage;
+ return;
+ default:
+ gl_problem(NULL, "bad target in set_tex_image()");
+ return;
+ }
+}
+
+
/*
* Return new gl_texture_image struct with all fields initialized to zero.
*/
@@ -475,6 +506,71 @@ _mesa_free_texture_image( struct gl_texture_image *teximage )
+/*
+ * Return the texture image struct which corresponds to target and level
+ * for the given texture unit.
+ */
+struct gl_texture_image *
+_mesa_select_tex_image(GLcontext *ctx, const struct gl_texture_unit *texUnit,
+ GLenum target, GLint level)
+{
+ ASSERT(texUnit);
+ switch (target) {
+ case GL_TEXTURE_1D:
+ return texUnit->CurrentD[1]->Image[level];
+ case GL_PROXY_TEXTURE_1D:
+ return ctx->Texture.Proxy1D->Image[level];
+ case GL_TEXTURE_2D:
+ return texUnit->CurrentD[2]->Image[level];
+ case GL_PROXY_TEXTURE_2D:
+ return ctx->Texture.Proxy2D->Image[level];
+ case GL_TEXTURE_3D:
+ return texUnit->CurrentD[3]->Image[level];
+ case GL_PROXY_TEXTURE_3D:
+ return ctx->Texture.Proxy3D->Image[level];
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
+ if (ctx->Extensions.HaveTextureCubeMap)
+ return texUnit->CurrentCubeMap->PosX[level];
+ else
+ return NULL;
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
+ if (ctx->Extensions.HaveTextureCubeMap)
+ return texUnit->CurrentCubeMap->NegX[level];
+ else
+ return NULL;
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
+ if (ctx->Extensions.HaveTextureCubeMap)
+ return texUnit->CurrentCubeMap->PosY[level];
+ else
+ return NULL;
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
+ if (ctx->Extensions.HaveTextureCubeMap)
+ return texUnit->CurrentCubeMap->NegY[level];
+ else
+ return NULL;
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
+ if (ctx->Extensions.HaveTextureCubeMap)
+ return texUnit->CurrentCubeMap->PosZ[level];
+ else
+ return NULL;
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
+ if (ctx->Extensions.HaveTextureCubeMap)
+ return texUnit->CurrentCubeMap->NegZ[level];
+ else
+ return NULL;
+ case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
+ if (ctx->Extensions.HaveTextureCubeMap)
+ return ctx->Texture.ProxyCubeMap->PosX[level];
+ else
+ return NULL;
+ default:
+ gl_problem(ctx, "bad target in _mesa_select_tex_image()");
+ return NULL;
+ }
+}
+
+
+
/* Need this to prevent an out-of-bounds memory access when using
* X86 optimized code.
*/
@@ -830,7 +926,15 @@ subtexture_error_check( GLcontext *ctx, GLuint dimensions,
}
}
else if (dimensions == 2) {
- if (target != GL_TEXTURE_2D) {
+ if (ctx->Extensions.HaveTextureCubeMap) {
+ if ((target < GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB ||
+ target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) &&
+ target != GL_TEXTURE_2D) {
+ gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" );
+ return GL_TRUE;
+ }
+ }
+ else if (target != GL_TEXTURE_2D) {
gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" );
return GL_TRUE;
}
@@ -928,18 +1032,25 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions,
{
GLint iformat;
- if (target != GL_TEXTURE_1D && target != GL_TEXTURE_2D) {
- gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage1/2D(target)" );
- return GL_TRUE;
- }
-
- if (dimensions == 1 && target != GL_TEXTURE_1D) {
- gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage1D(target)" );
- return GL_TRUE;
+ if (dimensions == 1) {
+ if (target != GL_TEXTURE_1D) {
+ gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage1D(target)" );
+ return GL_TRUE;
+ }
}
- else if (dimensions == 2 && target != GL_TEXTURE_2D) {
- gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" );
- return GL_TRUE;
+ else if (dimensions == 2) {
+ if (ctx->Extensions.HaveTextureCubeMap) {
+ if ((target < GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB ||
+ target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) &&
+ target != GL_TEXTURE_2D) {
+ gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" );
+ return GL_TRUE;
+ }
+ }
+ else if (target != GL_TEXTURE_2D) {
+ gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" );
+ return GL_TRUE;
+ }
}
/* Border */
@@ -1000,17 +1111,31 @@ copytexsubimage_error_check( GLcontext *ctx, GLuint dimensions,
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
struct gl_texture_image *teximage;
- if (dimensions == 1 && target != GL_TEXTURE_1D) {
- gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage1D(target)" );
- return GL_TRUE;
+ if (dimensions == 1) {
+ if (target != GL_TEXTURE_1D) {
+ gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage1D(target)" );
+ return GL_TRUE;
+ }
}
- else if (dimensions == 2 && target != GL_TEXTURE_2D) {
- gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage2D(target)" );
- return GL_TRUE;
+ else if (dimensions == 2) {
+ if (ctx->Extensions.HaveTextureCubeMap) {
+ if ((target < GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB ||
+ target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) &&
+ target != GL_TEXTURE_2D) {
+ gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage2D(target)" );
+ return GL_TRUE;
+ }
+ }
+ else if (target != GL_TEXTURE_2D) {
+ gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage2D(target)" );
+ return GL_TRUE;
+ }
}
- else if (dimensions == 3 && target != GL_TEXTURE_3D) {
- gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage3D(target)" );
- return GL_TRUE;
+ else if (dimensions == 3) {
+ if (target != GL_TEXTURE_3D) {
+ gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage3D(target)" );
+ return GL_TRUE;
+ }
}
if (level < 0 || level >= ctx->Const.MaxTextureLevels) {
@@ -1210,7 +1335,10 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexImage2D");
- if (target==GL_TEXTURE_2D) {
+ if (target==GL_TEXTURE_2D ||
+ (ctx->Extensions.HaveTextureCubeMap &&
+ target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) {
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
@@ -1222,11 +1350,12 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
texObj = select_tex_object(texUnit, target);
- texImage = texObj->Image[level];
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
if (!texImage) {
texImage = _mesa_alloc_texture_image();
- texObj->Image[level] = texImage;
+ set_tex_image(texObj, target, level, texImage);
+ /*texObj->Image[level] = texImage;*/
if (!texImage) {
gl_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
return;
diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h
index 9aa3a0714b..51e4720210 100644
--- a/src/mesa/main/teximage.h
+++ b/src/mesa/main/teximage.h
@@ -1,4 +1,4 @@
-/* $Id: teximage.h,v 1.6 2000/03/27 17:54:17 brianp Exp $ */
+/* $Id: teximage.h,v 1.7 2000/05/23 15:17:13 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -47,6 +47,11 @@ extern void
_mesa_free_texture_image( struct gl_texture_image *teximage );
+extern struct gl_texture_image *
+_mesa_select_tex_image(GLcontext *ctx, const struct gl_texture_unit *texUnit,
+ GLenum target, GLint level);
+
+
extern void
_mesa_get_teximage_from_driver( GLcontext *ctx, GLenum target, GLint level,
const struct gl_texture_object *texObj );
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 330943b579..cdd9aa475b 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -47,7 +47,7 @@
* table.
* Input: shared - the shared GL state structure to contain the texture object
* name - integer name for the texture object
- * dimensions - either 1, 2 or 3
+ * dimensions - either 1, 2, 3 or 6 (cube map)
* Return: pointer to new texture object
*/
struct gl_texture_object *
@@ -56,7 +56,7 @@ gl_alloc_texture_object( struct gl_shared_state *shared, GLuint name,
{
struct gl_texture_object *obj;
- ASSERT(dimensions <= 3);
+ ASSERT(dimensions <= 3 || dimensions == 6);
obj = CALLOC_STRUCT(gl_texture_object);
@@ -173,7 +173,7 @@ void gl_test_texture_object_completeness( const GLcontext *ctx, struct gl_textur
if (t->Dimensions==1) {
t->P = t->Image[0]->WidthLog2;
}
- else if (t->Dimensions==2) {
+ else if (t->Dimensions == 2 || t->Dimensions == 6) {
t->P = MAX2(t->Image[0]->WidthLog2, t->Image[0]->HeightLog2);
}
else if (t->Dimensions==3) {
@@ -428,25 +428,37 @@ _mesa_BindTexture( GLenum target, GLuint texName )
switch (target) {
case GL_TEXTURE_1D:
dim = 1;
+ oldTexObj = texUnit->CurrentD[1];
break;
case GL_TEXTURE_2D:
dim = 2;
+ oldTexObj = texUnit->CurrentD[2];
break;
case GL_TEXTURE_3D:
dim = 3;
+ oldTexObj = texUnit->CurrentD[3];
break;
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ if (ctx->Extensions.HaveTextureCubeMap) {
+ dim = 6;
+ oldTexObj = texUnit->CurrentCubeMap;
+ break;
+ }
+ /* fallthrough */
default:
gl_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" );
return;
}
- oldTexObj = texUnit->CurrentD[dim];
-
if (oldTexObj->Name == texName)
return;
- if (texName == 0)
- newTexObj = ctx->Shared->DefaultD[dim];
+ if (texName == 0) {
+ if (target == GL_TEXTURE_CUBE_MAP_ARB)
+ newTexObj = ctx->Shared->DefaultCubeMap;
+ else
+ newTexObj = ctx->Shared->DefaultD[dim];
+ }
else {
struct _mesa_HashTable *hash = ctx->Shared->TexObjects;
newTexObj = (struct gl_texture_object *) _mesa_HashLookup(hash, texName);
@@ -466,7 +478,22 @@ _mesa_BindTexture( GLenum target, GLuint texName )
newTexObj->RefCount++;
- texUnit->CurrentD[dim] = newTexObj;
+ switch (target) {
+ case GL_TEXTURE_1D:
+ texUnit->CurrentD[1] = newTexObj;
+ break;
+ case GL_TEXTURE_2D:
+ texUnit->CurrentD[2] = newTexObj;
+ break;
+ case GL_TEXTURE_3D:
+ texUnit->CurrentD[3] = newTexObj;
+ break;
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ texUnit->CurrentCubeMap = newTexObj;
+ break;
+ default:
+ gl_problem(ctx, "bad target in BindTexture");
+ }
/* If we've changed the CurrentD[123] texture object then update the
* ctx->Texture.Current pointer to point to the new texture object.
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 7d57f3ec63..4fe440ee15 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -1,4 +1,4 @@
-/* $Id: texstate.c,v 1.10 2000/05/22 16:33:21 brianp Exp $ */
+/* $Id: texstate.c,v 1.11 2000/05/23 15:17:13 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -35,6 +35,7 @@
#include "macros.h"
#include "matrix.h"
#include "texobj.h"
+#include "teximage.h"
#include "texstate.h"
#include "texture.h"
#include "types.h"
@@ -275,7 +276,7 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
break;
case GL_TEXTURE_CUBE_MAP_ARB:
if (ctx->Extensions.HaveTextureCubeMap) {
- texObj = texUnit->CurrentPosX;
+ texObj = texUnit->CurrentCubeMap;
break;
}
/* fallthrough */
@@ -431,6 +432,28 @@ _mesa_GetTexLevelParameterfv( GLenum target, GLint level,
}
+static GLuint
+tex_image_dimensions(GLcontext *ctx, GLenum target)
+{
+ switch (target) {
+ case GL_TEXTURE_1D:
+ case GL_PROXY_TEXTURE_1D:
+ return 1;
+ case GL_TEXTURE_2D:
+ case GL_PROXY_TEXTURE_2D:
+ return 2;
+ case GL_TEXTURE_3D:
+ case GL_PROXY_TEXTURE_3D:
+ return 3;
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
+ return ctx->Extensions.HaveTextureCubeMap ? 2 : 0;
+ default:
+ gl_problem(ctx, "bad target in _mesa_tex_target_dimensions()");
+ return 0;
+ }
+}
+
void
_mesa_GetTexLevelParameteriv( GLenum target, GLint level,
@@ -448,54 +471,12 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
return;
}
- switch (target) {
- case GL_TEXTURE_1D:
- img = texUnit->CurrentD[1]->Image[level];
- dimensions = 1;
- break;
- case GL_TEXTURE_2D:
- img = texUnit->CurrentD[2]->Image[level];
- dimensions = 2;
- break;
- case GL_TEXTURE_3D:
- img = texUnit->CurrentD[3]->Image[level];
- dimensions = 3;
- break;
- case GL_TEXTURE_CUBE_MAP_ARB:
- if (ctx->Extensions.HaveTextureCubeMap) {
- img = texUnit->CurrentPosX->Image[level];
- dimensions = 2;
- }
- else {
- gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)");
- return;
- }
- break;
- case GL_PROXY_TEXTURE_1D:
- img = ctx->Texture.Proxy1D->Image[level];
- dimensions = 1;
- break;
- case GL_PROXY_TEXTURE_2D:
- img = ctx->Texture.Proxy2D->Image[level];
- dimensions = 2;
- break;
- case GL_PROXY_TEXTURE_3D:
- img = ctx->Texture.Proxy3D->Image[level];
- dimensions = 3;
- break;
- case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
- if (ctx->Extensions.HaveTextureCubeMap) {
- img = ctx->Texture.ProxyCubeMap->Image[level];
- dimensions = 2;
- }
- else {
- gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)");
- return;
- }
- break;
- default:
- gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)");
- return;
+ dimensions = tex_image_dimensions(ctx, target); /* 1, 2 or 3 */
+ img = _mesa_select_tex_image(ctx, texUnit, target, level);
+
+ if (dimensions == 0) {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)");
+ return;
}
if (!img) {