/*
* 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"),
/**
* 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);
}
}
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);
}
}
void GLAPIENTRY
_mesa_DrawBuffer(GLenum buffer)
{
- GLuint bufferID;
GLbitfield destMask;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex... */
_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 */
_mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers)
{
GLint output;
- GLuint bufferID;
GLbitfield usedBufferMask, supportedMask;
GLbitfield destMask[MAX_DRAW_BUFFERS];
GET_CURRENT_CONTEXT(ctx);
return;
}
- bufferID = ctx->DrawBuffer->Name;
-
- supportedMask = supported_buffer_bitmask(ctx, bufferID);
+ supportedMask = supported_buffer_bitmask(ctx, ctx->DrawBuffer);
usedBufferMask = 0x0;
/* complicated error checking... */
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);
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;
}
_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;