diff options
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/buffers.c | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 11bd173e35..c280f89e1d 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.2 + * Version: 7.1 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -184,17 +184,19 @@ _mesa_Clear( GLbitfield mask ) /** * Return bitmask of BUFFER_BIT_* flags indicating which color buffers are - * available to the rendering context. - * This depends on the framebuffer we're writing to. For window system - * framebuffers we look at the framebuffer's visual. But for user- - * create framebuffers we look at the number of supported color attachments. + * available to the rendering context (for drawing or reading). + * This depends on the type of framebuffer. For window system framebuffers + * we look at the framebuffer's visual. But for user-create framebuffers we + * look at the number of supported color attachments. + * \param fb the framebuffer to draw to, or read from + * \return bitmask of BUFFER_BIT_* flags */ static GLbitfield -supported_buffer_bitmask(const GLcontext *ctx, GLuint framebufferID) +supported_buffer_bitmask(const GLcontext *ctx, const struct gl_framebuffer *fb) { GLbitfield mask = 0x0; - if (framebufferID > 0) { + if (fb->Name > 0) { /* A user-created renderbuffer */ GLuint i; ASSERT(ctx->Extensions.EXT_framebuffer_object); @@ -203,20 +205,20 @@ supported_buffer_bitmask(const GLcontext *ctx, GLuint framebufferID) } } else { - /* A window system renderbuffer */ + /* A window system framebuffer */ GLint i; mask = BUFFER_BIT_FRONT_LEFT; /* always have this */ - if (ctx->Visual.stereoMode) { + if (fb->Visual.stereoMode) { mask |= BUFFER_BIT_FRONT_RIGHT; - if (ctx->Visual.doubleBufferMode) { + if (fb->Visual.doubleBufferMode) { mask |= BUFFER_BIT_BACK_LEFT | BUFFER_BIT_BACK_RIGHT; } } - else if (ctx->Visual.doubleBufferMode) { + else if (fb->Visual.doubleBufferMode) { mask |= BUFFER_BIT_BACK_LEFT; } - for (i = 0; i < ctx->Visual.numAuxBuffers; i++) { + for (i = 0; i < fb->Visual.numAuxBuffers; i++) { mask |= (BUFFER_BIT_AUX0 << i); } } @@ -338,7 +340,6 @@ read_buffer_enum_to_index(GLenum buffer) void GLAPIENTRY _mesa_DrawBuffer(GLenum buffer) { - GLuint bufferID; GLbitfield destMask; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex... */ @@ -347,13 +348,12 @@ _mesa_DrawBuffer(GLenum buffer) _mesa_debug(ctx, "glDrawBuffer %s\n", _mesa_lookup_enum_by_nr(buffer)); } - bufferID = ctx->DrawBuffer->Name; - if (buffer == GL_NONE) { destMask = 0x0; } else { - const GLbitfield supportedMask = supported_buffer_bitmask(ctx, bufferID); + const GLbitfield supportedMask + = supported_buffer_bitmask(ctx, ctx->DrawBuffer); destMask = draw_buffer_enum_to_bitmask(buffer); if (destMask == BAD_MASK) { /* totally bogus buffer */ @@ -386,7 +386,6 @@ void GLAPIENTRY _mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers) { GLint output; - GLuint bufferID; GLbitfield usedBufferMask, supportedMask; GLbitfield destMask[MAX_DRAW_BUFFERS]; GET_CURRENT_CONTEXT(ctx); @@ -401,9 +400,7 @@ _mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers) return; } - bufferID = ctx->DrawBuffer->Name; - - supportedMask = supported_buffer_bitmask(ctx, bufferID); + supportedMask = supported_buffer_bitmask(ctx, ctx->DrawBuffer); usedBufferMask = 0x0; /* complicated error checking... */ @@ -492,8 +489,8 @@ _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, if (!destMask) { /* compute destMask values now */ - const GLuint bufferID = ctx->DrawBuffer->Name; - const GLbitfield supportedMask = supported_buffer_bitmask(ctx, bufferID); + const GLbitfield supportedMask + = supported_buffer_bitmask(ctx, ctx->DrawBuffer); for (output = 0; output < n; output++) { mask[output] = draw_buffer_enum_to_bitmask(buffers[output]); ASSERT(mask[output] != BAD_MASK); @@ -534,17 +531,15 @@ _mesa_ReadBuffer(GLenum buffer) struct gl_framebuffer *fb; GLbitfield supportedMask; GLint srcBuffer; - GLuint bufferID; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); fb = ctx->ReadBuffer; - bufferID = fb->Name; if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer)); - if (bufferID > 0 && buffer == GL_NONE) { + if (fb->Name > 0 && buffer == GL_NONE) { /* This is legal for user-created framebuffer objects */ srcBuffer = -1; } @@ -555,14 +550,14 @@ _mesa_ReadBuffer(GLenum buffer) _mesa_error(ctx, GL_INVALID_ENUM, "glReadBuffer(buffer=0x%x)", buffer); return; } - supportedMask = supported_buffer_bitmask(ctx, bufferID); + supportedMask = supported_buffer_bitmask(ctx, fb); if (((1 << srcBuffer) & supportedMask) == 0) { _mesa_error(ctx, GL_INVALID_OPERATION, "glReadBuffer(buffer=0x%x)", buffer); return; } } - if (bufferID == 0) { + if (fb->Name == 0) { ctx->Pixel.ReadBuffer = buffer; } fb->ColorReadBuffer = buffer; |