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

framebuffer.c File Reference

#include "glheader.h"
#include "imports.h"
#include "buffers.h"
#include "context.h"
#include "depthstencil.h"
#include "macros.h"
#include "mtypes.h"
#include "fbobject.h"
#include "framebuffer.h"
#include "renderbuffer.h"
#include "texobj.h"

Functions

static void compute_depth_max (struct gl_framebuffer *fb)
 Functions for allocating/managing framebuffers and renderbuffers.
struct gl_framebuffer_mesa_create_framebuffer (const GLvisual *visual)
 Create and initialize a gl_framebuffer object.
struct gl_framebuffer_mesa_new_framebuffer (GLcontext *ctx, GLuint name)
 Allocate a new gl_framebuffer object.
void _mesa_initialize_framebuffer (struct gl_framebuffer *fb, const GLvisual *visual)
 Initialize a gl_framebuffer object.
void _mesa_destroy_framebuffer (struct gl_framebuffer *fb)
 Deallocate buffer and everything attached to it.
void _mesa_free_framebuffer_data (struct gl_framebuffer *fb)
 Free all the data hanging off the given gl_framebuffer, but don't free the gl_framebuffer object itself.
void _mesa_reference_framebuffer (struct gl_framebuffer **ptr, struct gl_framebuffer *fb)
 Set *ptr to point to fb, with refcounting and locking.
void _mesa_resize_framebuffer (GLcontext *ctx, struct gl_framebuffer *fb, GLuint width, GLuint height)
 Resize the given framebuffer's renderbuffers to the new width and height.
void _mesa_resizebuffers (GLcontext *ctx)
 XXX THIS IS OBSOLETE - drivers should take care of detecting window size changes and act accordingly, likely calling _mesa_resize_framebuffer().
void GLAPIENTRY _mesa_ResizeBuffersMESA (void)
static void update_framebuffer_size (GLcontext *ctx, struct gl_framebuffer *fb)
 Examine all the framebuffer's renderbuffers to update the Width/Height fields of the framebuffer.
void _mesa_update_draw_buffer_bounds (GLcontext *ctx)
 Update the context's current drawing buffer's Xmin, Xmax, Ymin, Ymax fields.
void _mesa_update_framebuffer_visual (struct gl_framebuffer *fb)
 The glGet queries of the framebuffer red/green/blue size, stencil size, etc.
void _mesa_update_depth_buffer (GLcontext *ctx, struct gl_framebuffer *fb, GLuint attIndex)
 Update the framebuffer's _DepthBuffer field using the renderbuffer found at the given attachment index.
void _mesa_update_stencil_buffer (GLcontext *ctx, struct gl_framebuffer *fb, GLuint attIndex)
 Update the framebuffer's _StencilBuffer field using the renderbuffer found at the given attachment index.
static void update_color_draw_buffers (GLcontext *ctx, struct gl_framebuffer *fb)
 Update the (derived) list of color drawing renderbuffer pointers.
static void update_color_read_buffer (GLcontext *ctx, struct gl_framebuffer *fb)
 Update the (derived) color read renderbuffer pointer.
static void update_framebuffer (GLcontext *ctx, struct gl_framebuffer *fb)
 Update a gl_framebuffer's derived state.
void _mesa_update_framebuffer (GLcontext *ctx)
 Update state related to the current draw/read framebuffers.
GLboolean _mesa_source_buffer_exists (GLcontext *ctx, GLenum format)
 Check if the renderbuffer for a read operation (glReadPixels, glCopyPixels, glCopyTex[Sub]Image, etc) exists.
GLboolean _mesa_dest_buffer_exists (GLcontext *ctx, GLenum format)
 As above, but for drawing operations.


Function Documentation

struct gl_framebuffer* _mesa_create_framebuffer ( const GLvisual visual  )  [read]

Create and initialize a gl_framebuffer object.

This is intended for creating _window_system_ framebuffers, not generic framebuffer objects ala GL_EXT_framebuffer_object.

See also:
_mesa_new_framebuffer

GLboolean _mesa_dest_buffer_exists ( GLcontext ctx,
GLenum  format 
)

As above, but for drawing operations.

XXX could do some code merging w/ above function.

void _mesa_destroy_framebuffer ( struct gl_framebuffer fb  ) 

Deallocate buffer and everything attached to it.

Typically called via the gl_framebuffer->Delete() method.

void _mesa_free_framebuffer_data ( struct gl_framebuffer fb  ) 

Free all the data hanging off the given gl_framebuffer, but don't free the gl_framebuffer object itself.

void _mesa_initialize_framebuffer ( struct gl_framebuffer fb,
const GLvisual visual 
)

Initialize a gl_framebuffer object.

Typically used to initialize window system-created framebuffers, not user-created framebuffers.

See also:
_mesa_create_framebuffer

struct gl_framebuffer* _mesa_new_framebuffer ( GLcontext ctx,
GLuint  name 
) [read]

Allocate a new gl_framebuffer object.

This is the default function for ctx->Driver.NewFramebuffer(). This is for allocating user-created framebuffers, not window-system framebuffers!

See also:
_mesa_create_framebuffer

void _mesa_reference_framebuffer ( struct gl_framebuffer **  ptr,
struct gl_framebuffer fb 
)

Set *ptr to point to fb, with refcounting and locking.

void _mesa_resize_framebuffer ( GLcontext ctx,
struct gl_framebuffer fb,
GLuint  width,
GLuint  height 
)

Resize the given framebuffer's renderbuffers to the new width and height.

This should only be used for window-system framebuffers, not user-created renderbuffers (i.e. made with GL_EXT_framebuffer_object). This will typically be called via ctx->Driver.ResizeBuffers() or directly from a device driver.

Note:
it's possible for ctx to be null since a window can be resized without a currently bound rendering context.

void _mesa_resizebuffers ( GLcontext ctx  ) 

XXX THIS IS OBSOLETE - drivers should take care of detecting window size changes and act accordingly, likely calling _mesa_resize_framebuffer().

GL_MESA_resize_buffers extension.

When this function is called, we'll ask the window system how large the current window is. If it's a new size, we'll call the driver's ResizeBuffers function. The driver will then resize its color buffers as needed, and maybe call the swrast's routine for reallocating swrast-managed depth/stencil/accum/etc buffers.

Note:
This function should only be called through the GL API, not from device drivers (as was done in the past).

void GLAPIENTRY _mesa_ResizeBuffersMESA ( void   ) 

GLboolean _mesa_source_buffer_exists ( GLcontext ctx,
GLenum  format 
)

Check if the renderbuffer for a read operation (glReadPixels, glCopyPixels, glCopyTex[Sub]Image, etc) exists.

Parameters:
format a basic image format such as GL_RGB, GL_RGBA, GL_ALPHA, GL_DEPTH_COMPONENT, etc. or GL_COLOR, GL_DEPTH, GL_STENCIL.
Returns:
GL_TRUE if buffer exists, GL_FALSE otherwise

void _mesa_update_depth_buffer ( GLcontext ctx,
struct gl_framebuffer fb,
GLuint  attIndex 
)

Update the framebuffer's _DepthBuffer field using the renderbuffer found at the given attachment index.

If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer, create and install a depth wrapper/adaptor.

Parameters:
fb the framebuffer whose _DepthBuffer field to update
attIndex indicates the renderbuffer to possibly wrap

void _mesa_update_draw_buffer_bounds ( GLcontext ctx  ) 

Update the context's current drawing buffer's Xmin, Xmax, Ymin, Ymax fields.

These values are computed from the buffer's width and height and the scissor box, if it's enabled.

Parameters:
ctx the GL context.

void _mesa_update_framebuffer ( GLcontext ctx  ) 

Update state related to the current draw/read framebuffers.

void _mesa_update_framebuffer_visual ( struct gl_framebuffer fb  ) 

The glGet queries of the framebuffer red/green/blue size, stencil size, etc.

are satisfied by the fields of ctx->DrawBuffer->Visual. These can change depending on the renderbuffer bindings. This function updates the given framebuffer's Visual from the current renderbuffer bindings.

This may apply to user-created framebuffers or window system framebuffers.

Also note: ctx->DrawBuffer->Visual.depthBits might not equal ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer.DepthBits. The former one is used to convert floating point depth values into integer Z values.

void _mesa_update_stencil_buffer ( GLcontext ctx,
struct gl_framebuffer fb,
GLuint  attIndex 
)

Update the framebuffer's _StencilBuffer field using the renderbuffer found at the given attachment index.

If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer, create and install a stencil wrapper/adaptor.

Parameters:
fb the framebuffer whose _StencilBuffer field to update
attIndex indicates the renderbuffer to possibly wrap

static void compute_depth_max ( struct gl_framebuffer fb  )  [static]

Functions for allocating/managing framebuffers and renderbuffers.

Also, routines for reading/writing renderbuffer data as ubytes, ushorts, uints, etc. Compute/set the _DepthMax field for the given framebuffer. This value depends on the Z buffer resolution.

static void update_color_draw_buffers ( GLcontext ctx,
struct gl_framebuffer fb 
) [static]

Update the (derived) list of color drawing renderbuffer pointers.

Later, when we're rendering we'll loop from 0 to _NumColorDrawBuffers writing colors.

static void update_color_read_buffer ( GLcontext ctx,
struct gl_framebuffer fb 
) [static]

Update the (derived) color read renderbuffer pointer.

Unlike the DrawBuffer, we can only read from one (or zero) color buffers.

static void update_framebuffer ( GLcontext ctx,
struct gl_framebuffer fb 
) [static]

Update a gl_framebuffer's derived state.

Specifically, update these framebuffer fields: _ColorDrawBuffers _NumColorDrawBuffers _ColorReadBuffer _DepthBuffer _StencilBuffer

If the framebuffer is user-created, make sure it's complete.

The following functions (at least) can effect framebuffer state: glReadBuffer, glDrawBuffer, glDrawBuffersARB, glFramebufferRenderbufferEXT, glRenderbufferStorageEXT.

static void update_framebuffer_size ( GLcontext ctx,
struct gl_framebuffer fb 
) [static]

Examine all the framebuffer's renderbuffers to update the Width/Height fields of the framebuffer.

If we have renderbuffers with different sizes, set the framebuffer's width and height to the min size. Note: this is only intended for user-created framebuffers, not window-system framebuffes.


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