summaryrefslogtreecommitdiff
path: root/src/mesa/main/drawpix.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2005-09-28 16:20:34 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2005-09-28 16:20:34 +0000
commit5208867f12abd4b13c517e8cd006afde6fadbed8 (patch)
treed9276a9cb72701949c70e8c577aa008a0dade1f5 /src/mesa/main/drawpix.c
parentd95000da2fdad78f25618fe9703f23806587b65a (diff)
add error checks for framebuffer completeness
Diffstat (limited to 'src/mesa/main/drawpix.c')
-rw-r--r--src/mesa/main/drawpix.c45
1 files changed, 41 insertions, 4 deletions
diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
index de62909e7a..2872a03b2f 100644
--- a/src/mesa/main/drawpix.c
+++ b/src/mesa/main/drawpix.c
@@ -153,14 +153,20 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
return;
}
- if (!ctx->Current.RasterPosValid) {
- return; /* not an error */
- }
-
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)" );
+ return;
+ }
+
+ if (!ctx->Current.RasterPosValid) {
+ return;
+ }
+
if (ctx->RenderMode == GL_RENDER) {
/* Round, to satisfy conformance tests (matches SGI's OpenGL) */
GLint x = IROUND(ctx->Current.RasterPos[0]);
@@ -246,6 +252,13 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height,
_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,
+ "glCopyPixels(incomplete framebuffer)" );
+ return;
+ }
+
if (!ctx->Current.RasterPosValid) {
return;
}
@@ -281,6 +294,7 @@ _mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type, GLvoid *pixels )
{
GET_CURRENT_CONTEXT(ctx);
+ const struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
if (width < 0 || height < 0) {
@@ -297,6 +311,17 @@ _mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
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)" );
+ return;
+ }
+
+ if (!rb) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(no readbuffer)");
+ return;
+ }
+
ctx->Driver.ReadPixels(ctx, x, y, width, height,
format, type, &ctx->Pack, pixels);
}
@@ -330,6 +355,12 @@ _mesa_Bitmap( GLsizei width, GLsizei height,
_mesa_update_state(ctx);
}
+ if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+ _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
+ "glBitmap(incomplete framebuffer)");
+ return;
+ }
+
if (ctx->RenderMode == GL_RENDER) {
/* Truncate, to satisfy conformance tests (matches SGI's OpenGL). */
GLint x = IFLOOR(ctx->Current.RasterPos[0] - xorig);
@@ -390,6 +421,12 @@ _mesa_DrawDepthPixelsMESA( GLsizei width, GLsizei height,
_mesa_update_state(ctx);
}
+ if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+ _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
+ "glDrawDepthPixelsMESA(incomplete framebuffer)");
+ return;
+ }
+
if (ctx->RenderMode == GL_RENDER) {
/* Round, to satisfy conformance tests (matches SGI's OpenGL) */
GLint x = IROUND(ctx->Current.RasterPos[0]);