[cogl] Add a public cogl_framebuffer_get_depth_bits() function



commit 853143eb10387f50f8d32cf09af31b8829dc1e01
Author: Neil Roberts <neil linux intel com>
Date:   Thu Dec 13 15:47:35 2012 +0000

    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>

 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 |    1 +
 5 files changed, 33 insertions(+), 2 deletions(-)
---
diff --git a/cogl/cogl-framebuffer-private.h b/cogl/cogl-framebuffer-private.h
index 558a03d..bdff221 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 f049024..f43bca7 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -885,6 +885,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 789ef4b..918a36d 100644
--- a/cogl/cogl-framebuffer.h
+++ b/cogl/cogl-framebuffer.h
@@ -710,6 +710,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 d49b40a..cb1c203 100644
--- a/cogl/driver/gl/cogl-framebuffer-gl.c
+++ b/cogl/driver/gl/cogl-framebuffer-gl.c
@@ -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;
 }
diff --git a/doc/reference/cogl2/cogl2-sections.txt b/doc/reference/cogl2/cogl2-sections.txt
index 7d26283..235add3 100644
--- a/doc/reference/cogl2/cogl2-sections.txt
+++ b/doc/reference/cogl2/cogl2-sections.txt
@@ -461,6 +461,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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]