[Cogl] [PATCH 3/6] Add a public cogl_framebuffer_get_depth_bits() function
Neil Roberts
neil at linux.intel.com
Fri Dec 14 03:43:29 PST 2012
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.
---
cogl/cogl-framebuffer-private.h | 1 +
cogl/cogl-framebuffer.c | 11 +++++++++++
cogl/cogl-framebuffer.h | 14 ++++++++++++++
cogl/driver/gl/cogl-framebuffer-gl.c | 8 ++++++--
doc/reference/cogl2/cogl2-sections.txt | 3 ++-
5 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/cogl/cogl-framebuffer-private.h b/cogl/cogl-framebuffer-private.h
index 25f183b..6acf42c 100644
--- a/cogl/cogl-framebuffer-private.h
+++ b/cogl/cogl-framebuffer-private.h
@@ -111,6 +111,7 @@ typedef struct
int blue;
int green;
int alpha;
+ int depth;
} CoglFramebufferBits;
struct _CoglFramebuffer
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index 06dd388..771a7bf 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -887,6 +887,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)
{
diff --git a/cogl/cogl-framebuffer.h b/cogl/cogl-framebuffer.h
index 9dbea41..310d248 100644
--- a/cogl/cogl-framebuffer.h
+++ b/cogl/cogl-framebuffer.h
@@ -711,6 +711,20 @@ 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
*
diff --git a/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/driver/gl/cogl-framebuffer-gl.c
index e622d91..4ecc011 100644
--- a/cogl/driver/gl/cogl-framebuffer-gl.c
+++ b/cogl/driver/gl/cogl-framebuffer-gl.c
@@ -919,6 +919,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;
@@ -939,11 +941,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"
@@ -951,7 +954,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;
}
diff --git a/doc/reference/cogl2/cogl2-sections.txt b/doc/reference/cogl2/cogl2-sections.txt
index eea15d6..4767f3d 100644
--- a/doc/reference/cogl2/cogl2-sections.txt
+++ b/doc/reference/cogl2/cogl2-sections.txt
@@ -353,7 +353,8 @@ cogl_framebuffer_get_color_format
cogl_framebuffer_get_red_bits
cogl_framebuffer_get_green_bits
cogl_framebuffer_get_blue_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
--
1.7.11.3.g3c3efa5
More information about the Cogl
mailing list