core | glapi | vbo | math | shader | swrast | swrast_setup | tnl | tnl_dd

buffers.c File Reference


Detailed Description

glReadBuffer, DrawBuffer functions.

#include "glheader.h"
#include "buffers.h"
#include "colormac.h"
#include "context.h"
#include "enums.h"
#include "fbobject.h"
#include "state.h"

Defines

#define BAD_MASK   ~0u

Functions

static GLbitfield supported_buffer_bitmask (const GLcontext *ctx, const struct gl_framebuffer *fb)
 Return bitmask of BUFFER_BIT_* flags indicating which color buffers are available to the rendering context (for drawing or reading).
static GLbitfield draw_buffer_enum_to_bitmask (GLenum buffer)
 Helper routine used by glDrawBuffer and glDrawBuffersARB.
static GLint read_buffer_enum_to_index (GLenum buffer)
 Helper routine used by glReadBuffer.
void GLAPIENTRY _mesa_DrawBuffer (GLenum buffer)
 Called by glDrawBuffer().
void GLAPIENTRY _mesa_DrawBuffersARB (GLsizei n, const GLenum *buffers)
 Called by glDrawBuffersARB; specifies the destination color renderbuffers for N fragment program color outputs.
void _mesa_drawbuffers (GLcontext *ctx, GLuint n, const GLenum *buffers, const GLbitfield *destMask)
 Helper function to set the GL_DRAW_BUFFER state in the context and current FBO.
void _mesa_readbuffer (GLcontext *ctx, GLenum buffer, GLint bufferIndex)
 Like.
void GLAPIENTRY _mesa_ReadBuffer (GLenum buffer)
 Called by glReadBuffer to set the source renderbuffer for reading pixels.


Define Documentation

#define BAD_MASK   ~0u


Function Documentation

void GLAPIENTRY _mesa_DrawBuffer ( GLenum  buffer  ) 

Called by glDrawBuffer().

Specify which renderbuffer(s) to draw into for the first color output. <buffer> can name zero, one, two or four renderbuffers!

See also:
_mesa_DrawBuffersARB
Parameters:
buffer buffer token such as GL_LEFT or GL_FRONT_AND_BACK, etc.
Note that the behaviour of this function depends on whether the current ctx->DrawBuffer is a window-system framebuffer (Name=0) or a user-created framebuffer object (Name!=0). In the former case, we update the per-context ctx->Color.DrawBuffer state var _and_ the FB's ColorDrawBuffer state. In the later case, we update the FB's ColorDrawBuffer state only.

Furthermore, upon a MakeCurrent() or BindFramebuffer() call, if the new FB is a window system FB, we need to re-update the FB's ColorDrawBuffer state to match the context. This is handled in _mesa_update_framebuffer().

See the GL_EXT_framebuffer_object spec for more info.

void _mesa_drawbuffers ( GLcontext ctx,
GLuint  n,
const GLenum *  buffers,
const GLbitfield *  destMask 
)

Helper function to set the GL_DRAW_BUFFER state in the context and current FBO.

All error checking will have been done prior to calling this function so nothing should go wrong at this point.

Parameters:
ctx current context
n number of color outputs to set
buffers array[n] of colorbuffer names, like GL_LEFT.
destMask array[n] of BUFFER_BIT_* bitmasks which correspond to the colorbuffer names. (i.e. GL_FRONT_AND_BACK => BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT).

void GLAPIENTRY _mesa_DrawBuffersARB ( GLsizei  n,
const GLenum *  buffers 
)

Called by glDrawBuffersARB; specifies the destination color renderbuffers for N fragment program color outputs.

See also:
_mesa_DrawBuffer
Parameters:
n number of outputs
buffers array [n] of renderbuffer names. Unlike glDrawBuffer, the names cannot specify more than one buffer. For example, GL_FRONT_AND_BACK is illegal.

void GLAPIENTRY _mesa_ReadBuffer ( GLenum  buffer  ) 

Called by glReadBuffer to set the source renderbuffer for reading pixels.

Parameters:
mode color buffer such as GL_FRONT, GL_BACK, etc.

void _mesa_readbuffer ( GLcontext ctx,
GLenum  buffer,
GLint  bufferIndex 
)

Like.

See also:
_mesa_drawbuffers(), this is a helper function for setting GL_READ_BUFFER state in the context and current FBO.
Parameters:
ctx the rendering context
buffer GL_FRONT, GL_BACK, GL_COLOR_ATTACHMENT0, etc.
bufferIndex the numerical index corresponding to 'buffer'

static GLbitfield draw_buffer_enum_to_bitmask ( GLenum  buffer  )  [static]

Helper routine used by glDrawBuffer and glDrawBuffersARB.

Given a GLenum naming one or more color buffers (such as GL_FRONT_AND_BACK), return the corresponding bitmask of BUFFER_BIT_* flags.

static GLint read_buffer_enum_to_index ( GLenum  buffer  )  [static]

Helper routine used by glReadBuffer.

Given a GLenum naming a color buffer, return the index of the corresponding renderbuffer (a BUFFER_* value). return -1 for an invalid buffer.

static GLbitfield supported_buffer_bitmask ( const GLcontext ctx,
const struct gl_framebuffer fb 
) [static]

Return bitmask of BUFFER_BIT_* flags indicating which color buffers are 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.

Parameters:
fb the framebuffer to draw to, or read from
Returns:
bitmask of BUFFER_BIT_* flags


Generated on Sun Sep 27 06:47:45 2009 for Mesa Main by  doxygen 1.5.4