-/* $Id: get.c,v 1.62 2001/06/12 22:08:41 brianp Exp $ */
+/* $Id: get.c,v 1.63 2001/06/13 14:56:14 brianp Exp $ */
/*
* Mesa 3-D graphics library
*params = INT_TO_BOOL(MAX_PROJECTION_STACK_DEPTH);
break;
case GL_MAX_TEXTURE_SIZE:
+ *params = INT_TO_BOOL(1 << (ctx->Const.MaxTextureLevels - 1));
+ break;
case GL_MAX_3D_TEXTURE_SIZE:
- *params = INT_TO_BOOL(ctx->Const.MaxTextureSize);
+ *params = INT_TO_BOOL(1 << (ctx->Const.Max3DTextureLevels - 1));
break;
case GL_MAX_TEXTURE_STACK_DEPTH:
*params = INT_TO_BOOL(MAX_TEXTURE_STACK_DEPTH);
return;
case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
if (ctx->Extensions.ARB_texture_cube_map)
- *params = INT_TO_BOOL(ctx->Const.MaxCubeTextureSize);
+ *params = INT_TO_BOOL(1 << (ctx->Const.MaxCubeTextureLevels - 1));
else
_mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
break;
*params = (GLdouble) MAX_PROJECTION_STACK_DEPTH;
break;
case GL_MAX_TEXTURE_SIZE:
+ *params = (GLdouble) (1 << (ctx->Const.MaxTextureLevels - 1));
+ break;
case GL_MAX_3D_TEXTURE_SIZE:
- *params = (GLdouble) ctx->Const.MaxTextureSize;
+ *params = (GLdouble) (1 << (ctx->Const.Max3DTextureLevels - 1));
break;
case GL_MAX_TEXTURE_STACK_DEPTH:
*params = (GLdouble) MAX_TEXTURE_STACK_DEPTH;
return;
case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
if (ctx->Extensions.ARB_texture_cube_map)
- *params = (GLdouble) ctx->Const.MaxCubeTextureSize;
+ *params = (GLdouble) (1 << (ctx->Const.MaxCubeTextureLevels - 1));
else
_mesa_error(ctx, GL_INVALID_ENUM, "glGetDoublev");
return;
*params = (GLfloat) MAX_PROJECTION_STACK_DEPTH;
break;
case GL_MAX_TEXTURE_SIZE:
+ *params = (GLfloat) (1 << (ctx->Const.MaxTextureLevels - 1));
+ break;
case GL_MAX_3D_TEXTURE_SIZE:
- *params = (GLfloat) ctx->Const.MaxTextureSize;
+ *params = (GLfloat) (1 << (ctx->Const.Max3DTextureLevels - 1));
break;
case GL_MAX_TEXTURE_STACK_DEPTH:
*params = (GLfloat) MAX_TEXTURE_STACK_DEPTH;
return;
case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
if (ctx->Extensions.ARB_texture_cube_map)
- *params = (GLfloat) ctx->Const.MaxCubeTextureSize;
+ *params = (GLfloat) (1 << (ctx->Const.MaxCubeTextureLevels - 1));
else
_mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv");
return;
*params = (GLint) MAX_PROJECTION_STACK_DEPTH;
break;
case GL_MAX_TEXTURE_SIZE:
+ *params = (1 << (ctx->Const.MaxTextureLevels - 1));
+ break;
case GL_MAX_3D_TEXTURE_SIZE:
- *params = ctx->Const.MaxTextureSize;
+ *params = (1 << (ctx->Const.Max3DTextureLevels - 1));
break;
case GL_MAX_TEXTURE_STACK_DEPTH:
*params = (GLint) MAX_TEXTURE_STACK_DEPTH;
return;
case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
if (ctx->Extensions.ARB_texture_cube_map)
- *params = ctx->Const.MaxCubeTextureSize;
+ *params = (1 << (ctx->Const.MaxCubeTextureLevels - 1));
else
_mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv");
return;
-/* $Id: teximage.c,v 1.96 2001/06/12 22:05:34 brianp Exp $ */
+/* $Id: teximage.c,v 1.97 2001/06/13 14:56:14 brianp Exp $ */
/*
* Mesa 3-D graphics library
GLenum target, GLint level)
{
ASSERT(texUnit);
+ ASSERT(level < MAX_TEXTURE_LEVELS);
switch (target) {
case GL_TEXTURE_1D:
return texUnit->Current1D->Image[level];
{
GLboolean isProxy;
GLint iformat;
+ GLint maxLevels = 0, maxTextureSize;
if (dimensions == 1) {
isProxy = (GLboolean) (target == GL_PROXY_TEXTURE_1D);
_mesa_error( ctx, GL_INVALID_ENUM, "glTexImage1D(target)" );
return GL_TRUE;
}
+ maxLevels = ctx->Const.MaxTextureLevels;
}
else if (dimensions == 2) {
isProxy = (GLboolean) (target == GL_PROXY_TEXTURE_2D ||
_mesa_error( ctx, GL_INVALID_ENUM, "glTexImage2D(target)" );
return GL_TRUE;
}
+ if (target == GL_PROXY_TEXTURE_2D && target == GL_TEXTURE_2D)
+ maxLevels = ctx->Const.MaxTextureLevels;
+ else
+ maxLevels = ctx->Const.MaxCubeTextureLevels;
}
else if (dimensions == 3) {
isProxy = (GLboolean) (target == GL_PROXY_TEXTURE_3D);
_mesa_error( ctx, GL_INVALID_ENUM, "glTexImage3D(target)" );
return GL_TRUE;
}
+ maxLevels = ctx->Const.Max3DTextureLevels;
}
else {
_mesa_problem( ctx, "bad dims in texture_error_check" );
return GL_TRUE;
}
+ ASSERT(maxLevels > 0);
+ maxTextureSize = 1 << (maxLevels - 1);
+
/* Border */
if (border != 0 && border != 1) {
if (!isProxy) {
}
/* Width */
- if (width < 2 * border || width > 2 + ctx->Const.MaxTextureSize
+ if (width < 2 * border || width > 2 + maxTextureSize
|| logbase2( width - 2 * border ) < 0) {
if (!isProxy) {
char message[100];
/* Height */
if (dimensions >= 2) {
- if (height < 2 * border || height > 2 + ctx->Const.MaxTextureSize
+ if (height < 2 * border || height > 2 + maxTextureSize
|| logbase2( height - 2 * border ) < 0) {
if (!isProxy) {
char message[100];
/* Depth */
if (dimensions >= 3) {
- if (depth < 2 * border || depth > 2 + ctx->Const.MaxTextureSize
+ if (depth < 2 * border || depth > 2 + maxTextureSize
|| logbase2( depth - 2 * border ) < 0) {
if (!isProxy) {
char message[100];
}
/* Level */
- if (level < 0 || level >= ctx->Const.MaxTextureLevels) {
+ if (level < 0 || level >= maxLevels) {
if (!isProxy) {
char message[100];
sprintf(message, "glTexImage%dD(level=%d)", dimensions, level);
{
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
struct gl_texture_image *destTex;
+ GLint maxLevels = 0;
if (dimensions == 1) {
if (target != GL_TEXTURE_1D) {
_mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage1D(target)" );
return GL_TRUE;
}
+ maxLevels = ctx->Const.MaxTextureLevels;
}
else if (dimensions == 2) {
if (ctx->Extensions.ARB_texture_cube_map) {
_mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" );
return GL_TRUE;
}
+ if (target == GL_PROXY_TEXTURE_2D && target == GL_TEXTURE_2D)
+ maxLevels = ctx->Const.MaxTextureLevels;
+ else
+ maxLevels = ctx->Const.MaxCubeTextureLevels;
}
else if (dimensions == 3) {
if (target != GL_TEXTURE_3D) {
_mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage3D(target)" );
return GL_TRUE;
}
+ maxLevels = ctx->Const.Max3DTextureLevels;
}
else {
_mesa_problem( ctx, "bad dims in texture_error_check" );
return GL_TRUE;
}
- if (level < 0 || level >= ctx->Const.MaxTextureLevels) {
+ ASSERT(maxLevels > 0);
+
+ if (level < 0 || level >= maxLevels) {
char message[100];
sprintf(message, "glTexSubImage2D(level=%d)", level);
_mesa_error(ctx, GL_INVALID_ENUM, message);
GLint width, GLint height, GLint border )
{
GLint iformat;
+ GLint maxLevels = 0, maxTextureSize;
if (dimensions == 1) {
if (target != GL_TEXTURE_1D) {
_mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexImage1D(target)" );
return GL_TRUE;
}
+ maxLevels = ctx->Const.MaxTextureLevels;
}
else if (dimensions == 2) {
if (ctx->Extensions.ARB_texture_cube_map) {
_mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" );
return GL_TRUE;
}
+ if (target == GL_PROXY_TEXTURE_2D && target == GL_TEXTURE_2D)
+ maxLevels = ctx->Const.MaxTextureLevels;
+ else
+ maxLevels = ctx->Const.MaxCubeTextureLevels;
}
+ ASSERT(maxLevels > 0);
+ maxTextureSize = 1 << (maxLevels - 1);
+
/* Border */
if (border != 0 && border != 1) {
char message[100];
}
/* Width */
- if (width < 2 * border || width > 2 + ctx->Const.MaxTextureSize
+ if (width < 2 * border || width > 2 + maxTextureSize
|| logbase2( width - 2 * border ) < 0) {
char message[100];
sprintf(message, "glCopyTexImage%dD(width=%d)", dimensions, width);
/* Height */
if (dimensions >= 2) {
- if (height < 2 * border || height > 2 + ctx->Const.MaxTextureSize
+ if (height < 2 * border || height > 2 + maxTextureSize
|| logbase2( height - 2 * border ) < 0) {
char message[100];
sprintf(message, "glCopyTexImage%dD(height=%d)", dimensions, height);
}
/* Level */
- if (level < 0 || level>=ctx->Const.MaxTextureLevels) {
+ if (level < 0 || level >= maxLevels) {
char message[100];
sprintf(message, "glCopyTexImage%dD(level=%d)", dimensions, level);
_mesa_error(ctx, GL_INVALID_VALUE, message);
return GL_TRUE;
}
- iformat = _mesa_base_tex_format( ctx, internalFormat );
+ iformat = _mesa_base_tex_format(ctx, internalFormat);
if (iformat < 0) {
char message[100];
sprintf(message, "glCopyTexImage%dD(internalFormat)", dimensions);
{
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
struct gl_texture_image *teximage;
+ GLint maxLevels = 0;
if (dimensions == 1) {
if (target != GL_TEXTURE_1D) {
_mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage1D(target)" );
return GL_TRUE;
}
+ maxLevels = ctx->Const.MaxTextureLevels;
}
else if (dimensions == 2) {
if (ctx->Extensions.ARB_texture_cube_map) {
_mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage2D(target)" );
return GL_TRUE;
}
+ if (target == GL_PROXY_TEXTURE_2D && target == GL_TEXTURE_2D)
+ maxLevels = ctx->Const.MaxTextureLevels;
+ else
+ maxLevels = ctx->Const.MaxCubeTextureLevels;
}
else if (dimensions == 3) {
if (target != GL_TEXTURE_3D) {
_mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage3D(target)" );
return GL_TRUE;
}
+ maxLevels = ctx->Const.Max3DTextureLevels;
}
- if (level < 0 || level >= ctx->Const.MaxTextureLevels) {
+ ASSERT(maxLevels > 0);
+
+ if (level < 0 || level >= maxLevels) {
char message[100];
sprintf(message, "glCopyTexSubImage%dD(level=%d)", dimensions, level);
_mesa_error(ctx, GL_INVALID_VALUE, message);
const struct gl_texture_unit *texUnit;
const struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
+ GLint maxLevels = 0;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- if (level < 0 || level >= ctx->Const.MaxTextureLevels) {
+ texUnit = &(ctx->Texture.Unit[ctx->Texture.CurrentUnit]);
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ if (!texObj || is_proxy_target(target)) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target)");
+ 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);
+
+ if (level < 0 || level >= maxLevels) {
_mesa_error( ctx, GL_INVALID_VALUE, "glGetTexImage(level)" );
return;
}
if (!pixels)
return;
- texUnit = &(ctx->Texture.Unit[ctx->Texture.CurrentUnit]);
- texObj = _mesa_select_tex_object(ctx, texUnit, target);
- if (!texObj || is_proxy_target(target)) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target)");
- return;
- }
-
texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
if (!texImage) {
/* invalid mipmap level, not an error */
}
_mesa_pack_index_span(ctx, width, type, dest,
indexRow, &ctx->Pack,
- ctx->_ImageTransferState);
+ 0 /* no image transfer */);
}
else if (format == GL_DEPTH_COMPONENT) {
GLfloat depthRow[MAX_WIDTH];
}
_mesa_pack_rgba_span(ctx, width, (const GLchan (*)[4])rgba,
format, type, dest, &ctx->Pack,
- ctx->_ImageTransferState);
+ 0 /* no image transfer */);
} /* format */
} /* row */
} /* img */
}
if (error) {
/* if error, clear all proxy texture image parameters */
- if (level >= 0 && level < ctx->Const.MaxTextureLevels) {
+ const GLint maxLevels = (target == GL_PROXY_TEXTURE_2D) ?
+ ctx->Const.MaxTextureLevels : ctx->Const.MaxCubeTextureLevels;
+ if (level >= 0 && level < maxLevels) {
clear_teximage_fields(ctx->Texture.Proxy2D->Image[level]);
}
}
}
if (error) {
/* if error, clear all proxy texture image parameters */
- if (level >= 0 && level < ctx->Const.MaxTextureLevels) {
+ if (level >= 0 && level < ctx->Const.Max3DTextureLevels) {
clear_teximage_fields(ctx->Texture.Proxy3D->Image[level]);
}
}
}
}
else {
- _mesa_error( ctx, GL_INVALID_ENUM, "glCompressedTexImage1DARB(target)" );
+ _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage1DARB(target)");
return;
}
}
}
if (error) {
/* if error, clear all proxy texture image parameters */
- if (level >= 0 && level < ctx->Const.MaxTextureLevels) {
+ const GLint maxLevels = (target == GL_PROXY_TEXTURE_2D) ?
+ ctx->Const.MaxTextureLevels : ctx->Const.MaxCubeTextureLevels;
+ if (level >= 0 && level < maxLevels) {
clear_teximage_fields(ctx->Texture.Proxy2D->Image[level]);
}
}
}
else {
- _mesa_error( ctx, GL_INVALID_ENUM, "glCompressedTexImage2DARB(target)" );
+ _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage2DARB(target)");
return;
}
}
}
if (error) {
/* if error, clear all proxy texture image parameters */
- if (level >= 0 && level < ctx->Const.MaxTextureLevels) {
+ if (level >= 0 && level < ctx->Const.Max3DTextureLevels) {
clear_teximage_fields(ctx->Texture.Proxy3D->Image[level]);
}
}
}
else {
- _mesa_error( ctx, GL_INVALID_ENUM, "glCompressedTexImage3DARB(target)" );
+ _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage3DARB(target)");
return;
}
}
const struct gl_texture_unit *texUnit;
const struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
+ GLint maxLevels;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- if (level < 0 || level >= ctx->Const.MaxTextureLevels) {
- _mesa_error( ctx, GL_INVALID_VALUE, "glGetCompressedTexImageARB(level)" );
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ if (!texObj) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImageARB");
+ 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);
+
+ if (level < 0 || level >= maxLevels) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetCompressedTexImageARB(level)");
return;
}
return;
}
- texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- texObj = _mesa_select_tex_object(ctx, texUnit, target);
texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
-
if (!texImage) {
/* invalid mipmap level */
_mesa_error(ctx, GL_INVALID_VALUE, "glGetCompressedTexImageARB(level)");
-/* $Id: texobj.c,v 1.48 2001/04/25 18:21:05 brianp Exp $ */
+/* $Id: texobj.c,v 1.49 2001/06/13 14:56:14 brianp Exp $ */
/*
* Mesa 3-D graphics library
struct gl_texture_object *t )
{
const GLint baseLevel = t->BaseLevel;
- GLint maxLog2 = 0;
+ GLint maxLog2 = 0, maxLevels = 0;
t->Complete = GL_TRUE; /* be optimistic */
/* Compute _MaxLevel */
if (t->Dimensions == 1) {
maxLog2 = t->Image[baseLevel]->WidthLog2;
+ maxLevels = ctx->Const.MaxTextureLevels;
}
else if (t->Dimensions == 2 || t->Dimensions == 6) {
maxLog2 = MAX2(t->Image[baseLevel]->WidthLog2,
t->Image[baseLevel]->HeightLog2);
+ maxLevels = (t->Dimensions == 2) ?
+ ctx->Const.MaxTextureLevels : ctx->Const.MaxCubeTextureLevels;
}
else if (t->Dimensions == 3) {
GLint max = MAX2(t->Image[baseLevel]->WidthLog2,
t->Image[baseLevel]->HeightLog2);
maxLog2 = MAX2(max, (GLint)(t->Image[baseLevel]->DepthLog2));
+ maxLevels = ctx->Const.Max3DTextureLevels;
}
+ else {
+ _mesa_problem(ctx, "Bad t->Dimension in _mesa_test_texobj_completeness");
+ return;
+ }
+
+ ASSERT(maxLevels > 0);
t->_MaxLevel = baseLevel + maxLog2;
t->_MaxLevel = MIN2(t->_MaxLevel, t->MaxLevel);
- t->_MaxLevel = MIN2(t->_MaxLevel, ctx->Const.MaxTextureLevels - 1);
+ t->_MaxLevel = MIN2(t->_MaxLevel, maxLevels - 1);
/* Compute _MaxLambda = q - b (see the 1.2 spec) used during mipmapping */
t->_MaxLambda = (GLfloat) (t->_MaxLevel - t->BaseLevel);
if (t->Dimensions == 1) {
/* Test 1-D mipmaps */
GLuint width = t->Image[baseLevel]->Width2;
- for (i = baseLevel + 1; i < ctx->Const.MaxTextureLevels; i++) {
+ for (i = baseLevel + 1; i < maxLevels; i++) {
if (width > 1) {
width /= 2;
}
/* Test 2-D mipmaps */
GLuint width = t->Image[baseLevel]->Width2;
GLuint height = t->Image[baseLevel]->Height2;
- for (i = baseLevel + 1; i < ctx->Const.MaxTextureLevels; i++) {
+ for (i = baseLevel + 1; i < maxLevels; i++) {
if (width > 1) {
width /= 2;
}
GLuint width = t->Image[baseLevel]->Width2;
GLuint height = t->Image[baseLevel]->Height2;
GLuint depth = t->Image[baseLevel]->Depth2;
- for (i = baseLevel + 1; i < ctx->Const.MaxTextureLevels; i++) {
+ for (i = baseLevel + 1; i < maxLevels; i++) {
if (width > 1) {
width /= 2;
}
/* make sure 6 cube faces are consistant */
GLuint width = t->Image[baseLevel]->Width2;
GLuint height = t->Image[baseLevel]->Height2;
- for (i = baseLevel + 1; i < ctx->Const.MaxTextureLevels; i++) {
+ for (i = baseLevel + 1; i < maxLevels; i++) {
if (width > 1) {
width /= 2;
}