|
|
| static GLboolean texture_error_check |
( |
GLcontext * |
ctx, |
|
|
GLenum |
target, |
|
|
GLint |
level, |
|
|
GLint |
internalFormat, |
|
|
GLenum |
format, |
|
|
GLenum |
type, |
|
|
GLuint |
dimensions, |
|
|
GLint |
width, |
|
|
GLint |
height, |
|
|
GLint |
depth, |
|
|
GLint |
border |
|
) |
| [static] |
Test the glTexImage[123]D() parameters for errors.
- Parameters:
-
| ctx | GL context. |
| target | texture target given by the user. |
| level | image level given by the user. |
| internalFormat | internal format given by the user. |
| format | pixel data format given by the user. |
| type | pixel data type given by the user. |
| dimensions | texture image dimensions (must be 1, 2 or 3). |
| width | image width given by the user. |
| height | image height given by the user. |
| depth | image depth given by the user. |
| border | image border given by the user. |
- Returns:
- GL_TRUE if an error was detected, or GL_FALSE if no errors.
Verifies each of the parameters against the constants specified in __GLcontextRec::Const and the supported extensions, and according to the OpenGL specification.
Definition at line 1441 of file teximage.c.
Referenced by _mesa_TexImage1D(), _mesa_TexImage2D(), and _mesa_TexImage3D().
{
const GLboolean isProxy = _mesa_is_proxy_texture(target);
GLboolean sizeOK = GL_TRUE;
GLboolean colorFormat, indexFormat;
GLenum proxy_target;
if (level < 0 || level >= MAX_TEXTURE_LEVELS) {
if (!isProxy) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glTexImage%dD(level=%d)", dimensions, level);
}
return GL_TRUE;
}
if (border < 0 || border > 1 ||
((target == GL_TEXTURE_RECTANGLE_NV ||
target == GL_PROXY_TEXTURE_RECTANGLE_NV) && border != 0)) {
if (!isProxy) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glTexImage%dD(border=%d)", dimensions, border);
}
return GL_TRUE;
}
if (width < 0 || height < 0 || depth < 0) {
if (!isProxy) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glTexImage%dD(width, height or depth < 0)", dimensions);
}
return GL_TRUE;
}
if (dimensions == 1) {
if (target == GL_PROXY_TEXTURE_1D || target == GL_TEXTURE_1D) {
proxy_target = GL_PROXY_TEXTURE_1D;
height = 1;
depth = 1;
}
else {
_mesa_error( ctx, GL_INVALID_ENUM, "glTexImage1D(target)" );
return GL_TRUE;
}
}
else if (dimensions == 2) {
depth = 1;
if (target == GL_PROXY_TEXTURE_2D || target == GL_TEXTURE_2D) {
proxy_target = GL_PROXY_TEXTURE_2D;
}
else if (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB ||
(target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) {
if (!ctx->Extensions.ARB_texture_cube_map) {
_mesa_error(ctx, GL_INVALID_ENUM, "glTexImage2D(target)");
return GL_TRUE;
}
proxy_target = GL_PROXY_TEXTURE_CUBE_MAP_ARB;
sizeOK = (width == height);
}
else if (target == GL_PROXY_TEXTURE_RECTANGLE_NV ||
target == GL_TEXTURE_RECTANGLE_NV) {
if (!ctx->Extensions.NV_texture_rectangle) {
_mesa_error(ctx, GL_INVALID_ENUM, "glTexImage2D(target)");
return GL_TRUE;
}
proxy_target = GL_PROXY_TEXTURE_RECTANGLE_NV;
}
else if (target == GL_PROXY_TEXTURE_1D_ARRAY_EXT ||
target == GL_TEXTURE_1D_ARRAY_EXT) {
proxy_target = GL_PROXY_TEXTURE_1D_ARRAY_EXT;
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glTexImage2D(target)");
return GL_TRUE;
}
}
else if (dimensions == 3) {
if (target == GL_PROXY_TEXTURE_3D || target == GL_TEXTURE_3D) {
proxy_target = GL_PROXY_TEXTURE_3D;
}
else if (target == GL_PROXY_TEXTURE_2D_ARRAY_EXT ||
target == GL_TEXTURE_2D_ARRAY_EXT) {
proxy_target = GL_PROXY_TEXTURE_2D_ARRAY_EXT;
}
else {
_mesa_error( ctx, GL_INVALID_ENUM, "glTexImage3D(target)" );
return GL_TRUE;
}
}
else {
_mesa_problem( ctx, "bad dims in texture_error_check" );
return GL_TRUE;
}
sizeOK = sizeOK && ctx->Driver.TestProxyTexImage(ctx, proxy_target, level,
internalFormat, format,
type, width, height,
depth, border);
if (!sizeOK) {
if (!isProxy) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glTexImage%dD(level=%d, width=%d, height=%d, depth=%d)",
dimensions, level, width, height, depth);
}
return GL_TRUE;
}
if (_mesa_base_tex_format(ctx, internalFormat) < 0) {
if (!isProxy) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glTexImage%dD(internalFormat=0x%x)",
dimensions, internalFormat);
}
return GL_TRUE;
}
if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
if (!isProxy) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glTexImage%dD(format or type)", dimensions);
}
return GL_TRUE;
}
colorFormat = _mesa_is_color_format(format);
indexFormat = is_index_format(format);
if ((_mesa_is_color_format(internalFormat) && !colorFormat && !indexFormat) ||
(is_index_format(internalFormat) && !indexFormat) ||
(is_depth_format(internalFormat) != is_depth_format(format)) ||
(is_ycbcr_format(internalFormat) != is_ycbcr_format(format)) ||
(is_depthstencil_format(internalFormat) != is_depthstencil_format(format))) {
if (!isProxy)
_mesa_error(ctx, GL_INVALID_OPERATION,
"glTexImage(internalFormat/format)");
return GL_TRUE;
}
if (internalFormat == GL_YCBCR_MESA) {
ASSERT(ctx->Extensions.MESA_ycbcr_texture);
if (type != GL_UNSIGNED_SHORT_8_8_MESA &&
type != GL_UNSIGNED_SHORT_8_8_REV_MESA) {
char message[100];
_mesa_sprintf(message,
"glTexImage%d(format/type YCBCR mismatch", dimensions);
_mesa_error(ctx, GL_INVALID_ENUM, message);
return GL_TRUE;
}
if (target != GL_TEXTURE_2D &&
target != GL_PROXY_TEXTURE_2D &&
target != GL_TEXTURE_RECTANGLE_NV &&
target != GL_PROXY_TEXTURE_RECTANGLE_NV) {
if (!isProxy)
_mesa_error(ctx, GL_INVALID_ENUM, "glTexImage(target)");
return GL_TRUE;
}
if (border != 0) {
if (!isProxy) {
char message[100];
_mesa_sprintf(message,
"glTexImage%d(format=GL_YCBCR_MESA and border=%d)",
dimensions, border);
_mesa_error(ctx, GL_INVALID_VALUE, message);
}
return GL_TRUE;
}
}
if (_mesa_base_tex_format(ctx, internalFormat) == GL_DEPTH_COMPONENT) {
if (target != GL_TEXTURE_1D &&
target != GL_PROXY_TEXTURE_1D &&
target != GL_TEXTURE_2D &&
target != GL_PROXY_TEXTURE_2D &&
target != GL_TEXTURE_RECTANGLE_ARB &&
target != GL_PROXY_TEXTURE_RECTANGLE_ARB) {
if (!isProxy)
_mesa_error(ctx, GL_INVALID_ENUM,
"glTexImage(target/internalFormat)");
return GL_TRUE;
}
}
if (is_compressed_format(ctx, internalFormat)) {
if (!target_can_be_compressed(ctx, target) && !isProxy) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glTexImage%d(target)", dimensions);
return GL_TRUE;
}
if (border != 0) {
if (!isProxy) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glTexImage%D(border!=0)", dimensions);
}
return GL_TRUE;
}
}
return GL_FALSE;
}
|