/**
* Test glCopyTexSubImage[12]D() parameters for errors.
+ * Note that this is the first part of error checking.
+ * See also copytexsubimage_error_check2() below for the second part.
*
* \param ctx GL context.
* \param dimensions texture image dimensions (must be 1, 2 or 3).
* \param target texture target given by the user.
* \param level image level given by the user.
- * \param xoffset sub-image x offset given by the user.
- * \param yoffset sub-image y offset given by the user.
- * \param zoffset sub-image z offset given by the user.
- * \param width image width given by the user.
- * \param height image height given by the user.
*
* \return 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.
*/
static GLboolean
-copytexsubimage_error_check( GLcontext *ctx, GLuint dimensions,
- GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height)
+copytexsubimage_error_check1( GLcontext *ctx, GLuint dimensions,
+ GLenum target, GLint level)
{
- /* Check target */
/* Check that the source buffer is complete */
if (ctx->ReadBuffer->Name) {
_mesa_test_framebuffer_completeness(ctx, ctx->ReadBuffer);
}
}
+ /* Check target */
if (dimensions == 1) {
if (target != GL_TEXTURE_1D) {
_mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage1D(target)" );
return GL_TRUE;
}
- /* Check size */
- if (width < 0) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glCopyTexSubImage%dD(width=%d)", dimensions, width);
- return GL_TRUE;
- }
- if (dimensions > 1 && height < 0) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glCopyTexSubImage%dD(height=%d)", dimensions, height);
- return GL_TRUE;
- }
-
return GL_FALSE;
}
+
+/**
+ * Second part of error checking for glCopyTexSubImage[12]D().
+ * \param xoffset sub-image x offset given by the user.
+ * \param yoffset sub-image y offset given by the user.
+ * \param zoffset sub-image z offset given by the user.
+ * \param width image width given by the user.
+ * \param height image height given by the user.
+ */
static GLboolean
copytexsubimage_error_check2( GLcontext *ctx, GLuint dimensions,
GLenum target, GLint level,
GLsizei width, GLsizei height,
const struct gl_texture_image *teximage )
{
+ /* check that dest tex image exists */
if (!teximage) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glCopyTexSubImage%dD(undefined texture level: %d)",
return GL_TRUE;
}
+ /* Check size */
+ if (width < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%dD(width=%d)", dimensions, width);
+ return GL_TRUE;
+ }
+ if (dimensions > 1 && height < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%dD(height=%d)", dimensions, height);
+ return GL_TRUE;
+ }
+
+ /* check x/y offsets */
if (xoffset < -((GLint)teximage->Border)) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glCopyTexSubImage%dD(xoffset=%d)", dimensions, xoffset);
}
}
+ /* check z offset */
if (dimensions > 2) {
if (zoffset < -((GLint)teximage->Border)) {
_mesa_error(ctx, GL_INVALID_VALUE,
_mesa_update_state(ctx);
#if FEATURE_convolve
-
/* XXX should test internal format */
_mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL);
#endif
- if (copytexsubimage_error_check(ctx, 1, target, level,
- xoffset, 0, 0, postConvWidth, 1))
+ if (copytexsubimage_error_check1(ctx, 1, target, level))
return;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
_mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, &postConvHeight);
#endif
- if (copytexsubimage_error_check(ctx, 2, target, level, xoffset, yoffset, 0,
- postConvWidth, postConvHeight))
+ if (copytexsubimage_error_check1(ctx, 2, target, level))
return;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
_mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, &postConvHeight);
#endif
- if (copytexsubimage_error_check(ctx, 3, target, level, xoffset, yoffset,
- zoffset, postConvWidth, postConvHeight))
+ if (copytexsubimage_error_check1(ctx, 3, target, level))
return;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];