Add a public cogl_framebuffer_get_depth_bits() function

Cogl publicly exposes the depth buffer state so we might as well have
a function to query the number of depth bits of a framebuffer.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 853143eb10387f50f8d32cf09af31b8829dc1e01)
This commit is contained in:
Neil Roberts 2012-12-13 15:47:35 +00:00 committed by Robert Bragg
parent 0b01c91fc5
commit 109e576b1f
5 changed files with 33 additions and 2 deletions

View File

@ -111,6 +111,7 @@ typedef struct
int blue;
int green;
int alpha;
int depth;
} CoglFramebufferBits;
struct _CoglFramebuffer

View File

@ -1133,6 +1133,17 @@ cogl_framebuffer_get_alpha_bits (CoglFramebuffer *framebuffer)
return bits.alpha;
}
int
cogl_framebuffer_get_depth_bits (CoglFramebuffer *framebuffer)
{
CoglContext *ctx = framebuffer->context;
CoglFramebufferBits bits;
ctx->driver_vtable->framebuffer_query_bits (framebuffer, &bits);
return bits.depth;
}
CoglColorMask
cogl_framebuffer_get_color_mask (CoglFramebuffer *framebuffer)
{

View File

@ -719,6 +719,20 @@ cogl_framebuffer_get_blue_bits (CoglFramebuffer *framebuffer);
int
cogl_framebuffer_get_alpha_bits (CoglFramebuffer *framebuffer);
/**
* cogl_framebuffer_get_depth_bits:
* @framebuffer: a pointer to a #CoglFramebuffer
*
* Retrieves the number of depth bits of @framebuffer
*
* Return value: the number of bits
*
* Since: 2.0
* Stability: unstable
*/
int
cogl_framebuffer_get_depth_bits (CoglFramebuffer *framebuffer);
/**
* cogl_framebuffer_get_dither_enabled:
* @framebuffer: a pointer to a #CoglFramebuffer

View File

@ -920,6 +920,8 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
offsetof (CoglFramebufferBits, blue) },
{ GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE,
offsetof (CoglFramebufferBits, alpha) },
{ GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE,
offsetof (CoglFramebufferBits, depth) },
};
int i;
@ -940,11 +942,12 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
GE( ctx, glGetIntegerv (GL_GREEN_BITS, &framebuffer->bits.green) );
GE( ctx, glGetIntegerv (GL_BLUE_BITS, &framebuffer->bits.blue) );
GE( ctx, glGetIntegerv (GL_ALPHA_BITS, &framebuffer->bits.alpha) );
GE( ctx, glGetIntegerv (GL_DEPTH_BITS, &framebuffer->bits.depth) );
}
COGL_NOTE (OFFSCREEN,
"RGBA Bits for framebuffer[%p, %s]: %d, %d, %d, %d",
"RGBA/D Bits for framebuffer[%p, %s]: %d, %d, %d, %d, %d",
framebuffer,
framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN
? "offscreen"
@ -952,7 +955,8 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
framebuffer->bits.red,
framebuffer->bits.blue,
framebuffer->bits.green,
framebuffer->bits.alpha);
framebuffer->bits.alpha,
framebuffer->bits.depth);
framebuffer->dirty_bitmasks = FALSE;
}

View File

@ -511,6 +511,7 @@ cogl_framebuffer_get_red_bits
cogl_framebuffer_get_green_bits
cogl_framebuffer_get_blue_bits
cogl_framebuffer_get_alpha_bits
cogl_framebuffer_get_depth_bits
cogl_framebuffer_get_color_mask
cogl_framebuffer_set_color_mask
cogl_framebuffer_get_samples_per_pixel