[cogl/wip/cogl-1.14: 170/177] Add a public cogl_framebuffer_get_depth_bits() function



commit e5c7c8b9ce540fd20de238f97151b1e27173a2ed
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>
    
    (cherry picked from commit 853143eb10387f50f8d32cf09af31b8829dc1e01)

 cogl/cogl-framebuffer-private.h                    |    1 +
 cogl/cogl-framebuffer.c                            |   11 +++++++++++
 cogl/cogl-framebuffer.h                            |   14 ++++++++++++++
 cogl/driver/gl/cogl-framebuffer-gl.c               |    8 ++++++--
 .../cogl-2.0-experimental-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 996bc0a..4980003 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 8edf656..5fb626d 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -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)
 {
diff --git a/cogl/cogl-framebuffer.h b/cogl/cogl-framebuffer.h
index e3b7602..e3fdb12 100644
--- a/cogl/cogl-framebuffer.h
+++ b/cogl/cogl-framebuffer.h
@@ -720,6 +720,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 5888f72..753624a 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/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
index e6a4e93..ac74965 100644
--- a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
+++ b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
@@ -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



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