GLboolean drawing)
{
const char *readDraw = drawing ? "Draw" : "Read";
+ struct gl_framebuffer *fb = drawing ? ctx->DrawBuffer : ctx->ReadBuffer;
+
+ if (ctx->Extensions.EXT_packed_depth_stencil
+ && type == GL_UNSIGNED_INT_24_8_EXT
+ && format != GL_DEPTH_STENCIL_EXT) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "gl%sPixels(format is not GL_DEPTH_STENCIL_EXT)", readDraw);
+ return GL_TRUE;
+ }
/* basic combinations test */
if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
}
break;
case GL_STENCIL_INDEX:
- if (ctx->DrawBuffer->Visual.stencilBits == 0) {
+ if (fb->Visual.stencilBits == 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"gl%sPixels(no stencil buffer)", readDraw);
return GL_TRUE;
}
break;
case GL_DEPTH_COMPONENT:
- if (ctx->DrawBuffer->Visual.depthBits == 0) {
+ if (fb->Visual.depthBits == 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"gl%sPixels(no depth buffer)", readDraw);
return GL_TRUE;
_mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw);
return GL_TRUE;
}
- if (ctx->DrawBuffer->Visual.depthBits == 0 ||
- ctx->ReadBuffer->Visual.depthBits == 0 ||
- ctx->DrawBuffer->Visual.stencilBits == 0 ||
- ctx->ReadBuffer->Visual.stencilBits == 0) {
+ if (fb->Visual.depthBits == 0 || fb->Visual.stencilBits == 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"gl%sPixels(no depth or stencil buffer)", readDraw);
return GL_TRUE;
}
+ ASSERT(fb->Attachment[BUFFER_DEPTH].Renderbuffer);
+ ASSERT(fb->Attachment[BUFFER_STENCIL].Renderbuffer);
break;
default:
/* this should have been caught in _mesa_is_legal_format_type() */
return GL_TRUE;
}
- /* XXX might have to move this to the top of the function */
- if (type == GL_UNSIGNED_INT_24_8_EXT && format != GL_DEPTH_STENCIL_EXT) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "gl%sPixels(format is not GL_DEPTH_STENCIL_EXT)", readDraw);
- return GL_TRUE;
- }
-
/* no errors */
return GL_FALSE;
}
return;
}
+ if (ctx->NewState) {
+ _mesa_update_state(ctx);
+ }
+
if (error_check_format_type(ctx, format, type, GL_TRUE)) {
/* found an error */
return;
}
- if (ctx->NewState) {
- _mesa_update_state(ctx);
- }
-
if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
_mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
"glDrawPixels(incomplete framebuffer)" );
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+ if (ctx->NewState) {
+ _mesa_update_state(ctx);
+ }
+
if (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glCopyPixels (invalid fragment program)");
return;
}
- if (ctx->NewState) {
- _mesa_update_state(ctx);
- }
-
if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT ||
ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
_mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
return;
}
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+
if (error_check_format_type(ctx, format, type, GL_FALSE)) {
/* found an error */
return;
}
- if (ctx->NewState)
- _mesa_update_state(ctx);
-
if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
_mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
"glReadPixels(incomplete framebuffer)" );