diff options
author | Keith Whitwell <keithw@vmware.com> | 2009-02-16 19:50:48 +0000 |
---|---|---|
committer | Keith Whitwell <keithw@vmware.com> | 2009-02-16 19:50:48 +0000 |
commit | 59d54334c96f44ed1d8bf660dc96221362a77d04 (patch) | |
tree | e9ab34e568256bcdc2a88602c47072ab769211e8 /src/mesa/main/buffers.c | |
parent | 7c8836e9ef49d938aa55a1c385b95c6371c301f1 (diff) | |
parent | c5c383596ddb26cd75e4b355918ad16915283b59 (diff) |
Merge branch 'master' into gallium-texture-transfer
Conflicts:
src/mesa/state_tracker/st_cb_accum.c
src/mesa/state_tracker/st_cb_drawpixels.c
Diffstat (limited to 'src/mesa/main/buffers.c')
-rw-r--r-- | src/mesa/main/buffers.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 5dd85de272..85db3868c4 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -247,13 +247,14 @@ _mesa_DrawBuffer(GLenum buffer) destMask = draw_buffer_enum_to_bitmask(buffer); if (destMask == BAD_MASK) { /* totally bogus buffer */ - _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffer(buffer)"); + _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffer(buffer=0x%x)", buffer); return; } destMask &= supportedMask; if (destMask == 0x0) { /* none of the named color buffers exist! */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffer(buffer)"); + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawBuffer(buffer=0x%x)", buffer); return; } } @@ -289,11 +290,10 @@ _mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - if (!ctx->Extensions.ARB_draw_buffers) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffersARB"); - return; - } - if (n < 1 || n > (GLsizei) ctx->Const.MaxDrawBuffers) { + /* Turns out n==0 is a valid input that should not produce an error. + * The remaining code below correctly handles the n==0 case. + */ + if (n < 0 || n > (GLsizei) ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glDrawBuffersARB(n)"); return; } @@ -335,12 +335,14 @@ _mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers) _mesa_drawbuffers(ctx, n, buffers, destMask); /* - * Call device driver function. + * Call device driver function. Note that n can be equal to 0, + * in which case we don't want to reference buffers[0], which + * may not be valid. */ if (ctx->Driver.DrawBuffers) ctx->Driver.DrawBuffers(ctx, n, buffers); else if (ctx->Driver.DrawBuffer) - ctx->Driver.DrawBuffer(ctx, buffers[0]); + ctx->Driver.DrawBuffer(ctx, n>0? buffers[0]:GL_NONE); } |