summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2004-01-27 16:34:45 +0000
committerKeith Whitwell <[email protected]>2004-01-27 16:34:45 +0000
commit18fa367ac6e035341f5eb86ecc4231124b2921e3 (patch)
treee0902aabb61e55a785e8742aa809f53dcf5fa16c /src/mesa/main
parent740f7de085f143b2bb1fe623d68c5efb3560e1a7 (diff)
Consolidate texObj->Pos/Neg/X/Y/Z and texObj->Image into a single
array, texObj->Image[face][level].
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/mtypes.h22
-rw-r--r--src/mesa/main/teximage.c92
-rw-r--r--src/mesa/main/texobj.c179
-rw-r--r--src/mesa/main/texstore.c2
4 files changed, 128 insertions, 167 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 815f352701f..5e6777efec6 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1061,6 +1061,13 @@ struct gl_texture_image {
/*@}*/
};
+#define FACE_POS_X 0
+#define FACE_NEG_X 1
+#define FACE_POS_Y 2
+#define FACE_NEG_Y 3
+#define FACE_POS_Z 4
+#define FACE_NEG_Z 5
+#define MAX_FACES 6
/**
* Texture object record
@@ -1099,20 +1106,7 @@ struct gl_texture_object {
GLboolean GenerateMipmap; /**< GL_SGIS_generate_mipmap */
GLboolean _IsPowerOfTwo; /**< Are all image dimensions powers of two? */
- struct gl_texture_image *Image[MAX_TEXTURE_LEVELS];
-
- /**
- * \name Texture cube faces
- *
- * Image[] is alias for *PosX[MAX_TEXTURE_LEVELS];
- */
- /*@{*/
- struct gl_texture_image *NegX[MAX_TEXTURE_LEVELS];
- struct gl_texture_image *PosY[MAX_TEXTURE_LEVELS];
- struct gl_texture_image *NegY[MAX_TEXTURE_LEVELS];
- struct gl_texture_image *PosZ[MAX_TEXTURE_LEVELS];
- struct gl_texture_image *NegZ[MAX_TEXTURE_LEVELS];
- /*@}*/
+ struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
/** GL_EXT_paletted_texture */
struct gl_color_table Palette;
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index fd8e2d0cddd..ad7e20ce0fe 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -471,29 +471,22 @@ _mesa_set_tex_image(struct gl_texture_object *tObj,
case GL_TEXTURE_1D:
case GL_TEXTURE_2D:
case GL_TEXTURE_3D:
- tObj->Image[level] = texImage;
+ tObj->Image[0][level] = texImage;
return;
case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
- tObj->Image[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;
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: {
+ GLuint face = ((GLuint) target -
+ (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X);
+ tObj->Image[face][level] = texImage;
+ break;
+ }
case GL_TEXTURE_RECTANGLE_NV:
ASSERT(level == 0);
- tObj->Image[level] = texImage;
+ tObj->Image[0][level] = texImage;
return;
default:
_mesa_problem(NULL, "bad target in _mesa_set_tex_image()");
@@ -630,56 +623,39 @@ _mesa_select_tex_image(GLcontext *ctx, const struct gl_texture_unit *texUnit,
ASSERT(level < MAX_TEXTURE_LEVELS);
switch (target) {
case GL_TEXTURE_1D:
- return texUnit->Current1D->Image[level];
+ return texUnit->Current1D->Image[0][level];
case GL_PROXY_TEXTURE_1D:
- return ctx->Texture.Proxy1D->Image[level];
+ return ctx->Texture.Proxy1D->Image[0][level];
case GL_TEXTURE_2D:
- return texUnit->Current2D->Image[level];
+ return texUnit->Current2D->Image[0][level];
case GL_PROXY_TEXTURE_2D:
- return ctx->Texture.Proxy2D->Image[level];
+ return ctx->Texture.Proxy2D->Image[0][level];
case GL_TEXTURE_3D:
- return texUnit->Current3D->Image[level];
+ return texUnit->Current3D->Image[0][level];
case GL_PROXY_TEXTURE_3D:
- return ctx->Texture.Proxy3D->Image[level];
+ return ctx->Texture.Proxy3D->Image[0][level];
case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
- if (ctx->Extensions.ARB_texture_cube_map)
- return texUnit->CurrentCubeMap->Image[level];
- else
- return NULL;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
- if (ctx->Extensions.ARB_texture_cube_map)
- return texUnit->CurrentCubeMap->NegX[level];
- else
- return NULL;
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
- if (ctx->Extensions.ARB_texture_cube_map)
- return texUnit->CurrentCubeMap->PosY[level];
- else
- return NULL;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
- if (ctx->Extensions.ARB_texture_cube_map)
- return texUnit->CurrentCubeMap->NegY[level];
- else
- return NULL;
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
- if (ctx->Extensions.ARB_texture_cube_map)
- return texUnit->CurrentCubeMap->PosZ[level];
- else
- return NULL;
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
- if (ctx->Extensions.ARB_texture_cube_map)
- return texUnit->CurrentCubeMap->NegZ[level];
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
+ if (ctx->Extensions.ARB_texture_cube_map) {
+ GLuint face = ((GLuint) target -
+ (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X);
+ return texUnit->CurrentCubeMap->Image[face][level];
+ }
else
return NULL;
case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
if (ctx->Extensions.ARB_texture_cube_map)
- return ctx->Texture.ProxyCubeMap->Image[level];
+ return ctx->Texture.ProxyCubeMap->Image[0][level];
else
return NULL;
case GL_TEXTURE_RECTANGLE_NV:
if (ctx->Extensions.NV_texture_rectangle) {
ASSERT(level == 0);
- return texUnit->CurrentRect->Image[level];
+ return texUnit->CurrentRect->Image[0][level];
}
else {
return NULL;
@@ -687,7 +663,7 @@ _mesa_select_tex_image(GLcontext *ctx, const struct gl_texture_unit *texUnit,
case GL_PROXY_TEXTURE_RECTANGLE_NV:
if (ctx->Extensions.NV_texture_rectangle) {
ASSERT(level == 0);
- return ctx->Texture.ProxyRect->Image[level];
+ return ctx->Texture.ProxyRect->Image[0][level];
}
else {
return NULL;
@@ -743,66 +719,66 @@ _mesa_get_proxy_tex_image(GLcontext *ctx, GLenum target, GLint level)
case GL_PROXY_TEXTURE_1D:
if (level >= ctx->Const.MaxTextureLevels)
return NULL;
- texImage = ctx->Texture.Proxy1D->Image[level];
+ texImage = ctx->Texture.Proxy1D->Image[0][level];
if (!texImage) {
texImage = ctx->Driver.NewTextureImage(ctx);
if (!texImage) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation");
return NULL;
}
- ctx->Texture.Proxy1D->Image[level] = texImage;
+ ctx->Texture.Proxy1D->Image[0][level] = texImage;
}
return texImage;
case GL_PROXY_TEXTURE_2D:
if (level >= ctx->Const.MaxTextureLevels)
return NULL;
- texImage = ctx->Texture.Proxy2D->Image[level];
+ texImage = ctx->Texture.Proxy2D->Image[0][level];
if (!texImage) {
texImage = ctx->Driver.NewTextureImage(ctx);
if (!texImage) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation");
return NULL;
}
- ctx->Texture.Proxy2D->Image[level] = texImage;
+ ctx->Texture.Proxy2D->Image[0][level] = texImage;
}
return texImage;
case GL_PROXY_TEXTURE_3D:
if (level >= ctx->Const.Max3DTextureLevels)
return NULL;
- texImage = ctx->Texture.Proxy3D->Image[level];
+ texImage = ctx->Texture.Proxy3D->Image[0][level];
if (!texImage) {
texImage = ctx->Driver.NewTextureImage(ctx);
if (!texImage) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation");
return NULL;
}
- ctx->Texture.Proxy3D->Image[level] = texImage;
+ ctx->Texture.Proxy3D->Image[0][level] = texImage;
}
return texImage;
case GL_PROXY_TEXTURE_CUBE_MAP:
if (level >= ctx->Const.MaxCubeTextureLevels)
return NULL;
- texImage = ctx->Texture.ProxyCubeMap->Image[level];
+ texImage = ctx->Texture.ProxyCubeMap->Image[0][level];
if (!texImage) {
texImage = ctx->Driver.NewTextureImage(ctx);
if (!texImage) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation");
return NULL;
}
- ctx->Texture.ProxyCubeMap->Image[level] = texImage;
+ ctx->Texture.ProxyCubeMap->Image[0][level] = texImage;
}
return texImage;
case GL_PROXY_TEXTURE_RECTANGLE_NV:
if (level > 0)
return NULL;
- texImage = ctx->Texture.ProxyRect->Image[level];
+ texImage = ctx->Texture.ProxyRect->Image[0][level];
if (!texImage) {
texImage = ctx->Driver.NewTextureImage(ctx);
if (!texImage) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation");
return NULL;
}
- ctx->Texture.ProxyRect->Image[level] = texImage;
+ ctx->Texture.ProxyRect->Image[0][level] = texImage;
}
return texImage;
default:
@@ -2170,7 +2146,7 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
1, border)) {
/* when error, clear all proxy texture image parameters */
if (texImage)
- clear_teximage_fields(ctx->Texture.Proxy2D->Image[level]);
+ clear_teximage_fields(ctx->Texture.Proxy2D->Image[0][level]);
}
else {
/* no error, set the tex image parameters */
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 98e49cde672..cdcc5acc754 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -133,7 +133,7 @@ _mesa_initialize_texture_object( struct gl_texture_object *obj,
void
_mesa_delete_texture_object( GLcontext *ctx, struct gl_texture_object *texObj )
{
- GLuint i;
+ GLuint i, face;
(void) ctx;
@@ -142,9 +142,11 @@ _mesa_delete_texture_object( GLcontext *ctx, struct gl_texture_object *texObj )
_mesa_free_colortable_data(&texObj->Palette);
/* free the texture images */
- for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
- if (texObj->Image[i]) {
- _mesa_delete_texture_image( texObj->Image[i] );
+ for (face = 0; face < 6; face++) {
+ for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
+ if (texObj->Image[face][i]) {
+ _mesa_delete_texture_image( texObj->Image[face][i] );
+ }
}
}
@@ -295,7 +297,7 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
t->_IsPowerOfTwo = GL_TRUE; /* may be set FALSE below */
/* Always need the base level image */
- if (!t->Image[baseLevel]) {
+ if (!t->Image[0][baseLevel]) {
char s[100];
sprintf(s, "obj %p (%d) Image[baseLevel=%d] == NULL",
(void *) t, t->Name, baseLevel);
@@ -305,9 +307,9 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
}
/* Check width/height/depth for zero */
- if (t->Image[baseLevel]->Width == 0 ||
- t->Image[baseLevel]->Height == 0 ||
- t->Image[baseLevel]->Depth == 0) {
+ if (t->Image[0][baseLevel]->Width == 0 ||
+ t->Image[0][baseLevel]->Height == 0 ||
+ t->Image[0][baseLevel]->Depth == 0) {
incomplete(t, "texture width = 0");
t->Complete = GL_FALSE;
return;
@@ -315,23 +317,23 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
/* Compute _MaxLevel */
if (t->Target == GL_TEXTURE_1D) {
- maxLog2 = t->Image[baseLevel]->WidthLog2;
+ maxLog2 = t->Image[0][baseLevel]->WidthLog2;
maxLevels = ctx->Const.MaxTextureLevels;
}
else if (t->Target == GL_TEXTURE_2D) {
- maxLog2 = MAX2(t->Image[baseLevel]->WidthLog2,
- t->Image[baseLevel]->HeightLog2);
+ maxLog2 = MAX2(t->Image[0][baseLevel]->WidthLog2,
+ t->Image[0][baseLevel]->HeightLog2);
maxLevels = ctx->Const.MaxTextureLevels;
}
else if (t->Target == GL_TEXTURE_3D) {
- GLint max = MAX2(t->Image[baseLevel]->WidthLog2,
- t->Image[baseLevel]->HeightLog2);
- maxLog2 = MAX2(max, (GLint)(t->Image[baseLevel]->DepthLog2));
+ GLint max = MAX2(t->Image[0][baseLevel]->WidthLog2,
+ t->Image[0][baseLevel]->HeightLog2);
+ maxLog2 = MAX2(max, (GLint)(t->Image[0][baseLevel]->DepthLog2));
maxLevels = ctx->Const.Max3DTextureLevels;
}
else if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) {
- maxLog2 = MAX2(t->Image[baseLevel]->WidthLog2,
- t->Image[baseLevel]->HeightLog2);
+ maxLog2 = MAX2(t->Image[0][baseLevel]->WidthLog2,
+ t->Image[0][baseLevel]->HeightLog2);
maxLevels = ctx->Const.MaxCubeTextureLevels;
}
else if (t->Target == GL_TEXTURE_RECTANGLE_NV) {
@@ -354,31 +356,22 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) {
/* make sure that all six cube map level 0 images are the same size */
- const GLuint w = t->Image[baseLevel]->Width2;
- const GLuint h = t->Image[baseLevel]->Height2;
- if (!t->NegX[baseLevel] ||
- t->NegX[baseLevel]->Width2 != w ||
- t->NegX[baseLevel]->Height2 != h ||
- !t->PosY[baseLevel] ||
- t->PosY[baseLevel]->Width2 != w ||
- t->PosY[baseLevel]->Height2 != h ||
- !t->NegY[baseLevel] ||
- t->NegY[baseLevel]->Width2 != w ||
- t->NegY[baseLevel]->Height2 != h ||
- !t->PosZ[baseLevel] ||
- t->PosZ[baseLevel]->Width2 != w ||
- t->PosZ[baseLevel]->Height2 != h ||
- !t->NegZ[baseLevel] ||
- t->NegZ[baseLevel]->Width2 != w ||
- t->NegZ[baseLevel]->Height2 != h) {
- t->Complete = GL_FALSE;
- incomplete(t, "Non-quare cubemap image");
- return;
+ const GLuint w = t->Image[0][baseLevel]->Width2;
+ const GLuint h = t->Image[0][baseLevel]->Height2;
+ GLuint face;
+ for (face = 1; face < 6; face++) {
+ if (t->Image[face][baseLevel] == NULL ||
+ t->Image[face][baseLevel]->Width2 != w ||
+ t->Image[face][baseLevel]->Height2 != h) {
+ t->Complete = GL_FALSE;
+ incomplete(t, "Non-quare cubemap image");
+ return;
+ }
}
}
/* check for non power of two */
- if (!t->Image[baseLevel]->_IsPowerOfTwo) {
+ if (!t->Image[0][baseLevel]->_IsPowerOfTwo) {
t->_IsPowerOfTwo = GL_FALSE;
}
@@ -399,13 +392,13 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
/* Test dimension-independent attributes */
for (i = minLevel; i <= maxLevel; i++) {
- if (t->Image[i]) {
- if (t->Image[i]->TexFormat != t->Image[baseLevel]->TexFormat) {
+ if (t->Image[0][i]) {
+ if (t->Image[0][i]->TexFormat != t->Image[0][baseLevel]->TexFormat) {
t->Complete = GL_FALSE;
incomplete(t, "Format[i] != Format[baseLevel]");
return;
}
- if (t->Image[i]->Border != t->Image[baseLevel]->Border) {
+ if (t->Image[0][i]->Border != t->Image[0][baseLevel]->Border) {
t->Complete = GL_FALSE;
incomplete(t, "Border[i] != Border[baseLevel]");
return;
@@ -416,20 +409,20 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
/* Test things which depend on number of texture image dimensions */
if (t->Target == GL_TEXTURE_1D) {
/* Test 1-D mipmaps */
- GLuint width = t->Image[baseLevel]->Width2;
+ GLuint width = t->Image[0][baseLevel]->Width2;
for (i = baseLevel + 1; i < maxLevels; i++) {
if (width > 1) {
width /= 2;
}
if (i >= minLevel && i <= maxLevel) {
- if (!t->Image[i]) {
+ if (!t->Image[0][i]) {
t->Complete = GL_FALSE;
- incomplete(t, "1D Image[i] == NULL");
+ incomplete(t, "1D Image[0][i] == NULL");
return;
}
- if (t->Image[i]->Width2 != width ) {
+ if (t->Image[0][i]->Width2 != width ) {
t->Complete = GL_FALSE;
- incomplete(t, "1D Image[i] bad width");
+ incomplete(t, "1D Image[0][i] bad width");
return;
}
}
@@ -440,8 +433,8 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
}
else if (t->Target == GL_TEXTURE_2D) {
/* Test 2-D mipmaps */
- GLuint width = t->Image[baseLevel]->Width2;
- GLuint height = t->Image[baseLevel]->Height2;
+ GLuint width = t->Image[0][baseLevel]->Width2;
+ GLuint height = t->Image[0][baseLevel]->Height2;
for (i = baseLevel + 1; i < maxLevels; i++) {
if (width > 1) {
width /= 2;
@@ -450,19 +443,19 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
height /= 2;
}
if (i >= minLevel && i <= maxLevel) {
- if (!t->Image[i]) {
+ if (!t->Image[0][i]) {
t->Complete = GL_FALSE;
- incomplete(t, "2D Image[i] == NULL");
+ incomplete(t, "2D Image[0][i] == NULL");
return;
}
- if (t->Image[i]->Width2 != width) {
+ if (t->Image[0][i]->Width2 != width) {
t->Complete = GL_FALSE;
- incomplete(t, "2D Image[i] bad width");
+ incomplete(t, "2D Image[0][i] bad width");
return;
}
- if (t->Image[i]->Height2 != height) {
+ if (t->Image[0][i]->Height2 != height) {
t->Complete = GL_FALSE;
- incomplete(t, "2D Image[i] bad height");
+ incomplete(t, "2D Image[0][i] bad height");
return;
}
if (width==1 && height==1) {
@@ -473,9 +466,9 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
}
else if (t->Target == GL_TEXTURE_3D) {
/* Test 3-D mipmaps */
- GLuint width = t->Image[baseLevel]->Width2;
- GLuint height = t->Image[baseLevel]->Height2;
- GLuint depth = t->Image[baseLevel]->Depth2;
+ GLuint width = t->Image[0][baseLevel]->Width2;
+ GLuint height = t->Image[0][baseLevel]->Height2;
+ GLuint depth = t->Image[0][baseLevel]->Depth2;
for (i = baseLevel + 1; i < maxLevels; i++) {
if (width > 1) {
width /= 2;
@@ -487,29 +480,29 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
depth /= 2;
}
if (i >= minLevel && i <= maxLevel) {
- if (!t->Image[i]) {
- incomplete(t, "3D Image[i] == NULL");
+ if (!t->Image[0][i]) {
+ incomplete(t, "3D Image[0][i] == NULL");
t->Complete = GL_FALSE;
return;
}
- if (t->Image[i]->Format == GL_DEPTH_COMPONENT) {
+ if (t->Image[0][i]->Format == GL_DEPTH_COMPONENT) {
t->Complete = GL_FALSE;
incomplete(t, "GL_DEPTH_COMPONENT only works with 1/2D tex");
return;
}
- if (t->Image[i]->Width2 != width) {
+ if (t->Image[0][i]->Width2 != width) {
t->Complete = GL_FALSE;
- incomplete(t, "3D Image[i] bad width");
+ incomplete(t, "3D Image[0][i] bad width");
return;
}
- if (t->Image[i]->Height2 != height) {
+ if (t->Image[0][i]->Height2 != height) {
t->Complete = GL_FALSE;
- incomplete(t, "3D Image[i] bad height");
+ incomplete(t, "3D Image[0][i] bad height");
return;
}
- if (t->Image[i]->Depth2 != depth) {
+ if (t->Image[0][i]->Depth2 != depth) {
t->Complete = GL_FALSE;
- incomplete(t, "3D Image[i] bad depth");
+ incomplete(t, "3D Image[0][i] bad depth");
return;
}
}
@@ -520,8 +513,8 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
}
else if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) {
/* make sure 6 cube faces are consistant */
- GLuint width = t->Image[baseLevel]->Width2;
- GLuint height = t->Image[baseLevel]->Height2;
+ GLuint width = t->Image[0][baseLevel]->Width2;
+ GLuint height = t->Image[0][baseLevel]->Height2;
for (i = baseLevel + 1; i < maxLevels; i++) {
if (width > 1) {
width /= 2;
@@ -530,33 +523,31 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
height /= 2;
}
if (i >= minLevel && i <= maxLevel) {
- /* check that we have images defined */
- if (!t->Image[i] || !t->NegX[i] ||
- !t->PosY[i] || !t->NegY[i] ||
- !t->PosZ[i] || !t->NegZ[i]) {
- t->Complete = GL_FALSE;
- incomplete(t, "CubeMap Image[i] == NULL");
- return;
- }
- /* Don't support GL_DEPTH_COMPONENT for cube maps */
- if (t->Image[i]->Format == GL_DEPTH_COMPONENT) {
- t->Complete = GL_FALSE;
- incomplete(t, "GL_DEPTH_COMPONENT only works with 1/2D tex");
- return;
- }
- /* check that all six images have same size */
- if (t->NegX[i]->Width2!=width || t->NegX[i]->Height2!=height ||
- t->PosY[i]->Width2!=width || t->PosY[i]->Height2!=height ||
- t->NegY[i]->Width2!=width || t->NegY[i]->Height2!=height ||
- t->PosZ[i]->Width2!=width || t->PosZ[i]->Height2!=height ||
- t->NegZ[i]->Width2!=width || t->NegZ[i]->Height2!=height) {
- t->Complete = GL_FALSE;
- incomplete(t, "CubeMap Image[i] bad size");
- return;
- }
- }
- if (width == 1 && height == 1) {
- return; /* found smallest needed mipmap, all done! */
+ GLuint face;
+ for (face = 0; face < 6; face++) {
+ /* check that we have images defined */
+ if (!t->Image[face][i]) {
+ t->Complete = GL_FALSE;
+ incomplete(t, "CubeMap Image[n][i] == NULL");
+ return;
+ }
+ /* Don't support GL_DEPTH_COMPONENT for cube maps */
+ if (t->Image[face][i]->Format == GL_DEPTH_COMPONENT) {
+ t->Complete = GL_FALSE;
+ incomplete(t, "GL_DEPTH_COMPONENT only works with 1/2D tex");
+ return;
+ }
+ /* check that all six images have same size */
+ if (t->Image[face][i]->Width2!=width ||
+ t->Image[face][i]->Height2!=height) {
+ t->Complete = GL_FALSE;
+ incomplete(t, "CubeMap Image[n][i] bad size");
+ return;
+ }
+ }
+ }
+ if (width == 1 && height == 1) {
+ return; /* found smallest needed mipmap, all done! */
}
}
}
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index db51aebc9a9..3e73de29b00 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -1874,7 +1874,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
GLint level, maxLevels;
ASSERT(texObj);
- srcImage = texObj->Image[texObj->BaseLevel];
+ srcImage = texObj->Image[0][texObj->BaseLevel];
ASSERT(srcImage);
maxLevels = _mesa_max_texture_levels(ctx, texObj->Target);