summaryrefslogtreecommitdiff
path: root/cogl/cogl-framebuffer.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@linux.intel.com>2010-05-21 14:38:37 +0100
committerEmmanuele Bassi <ebassi@linux.intel.com>2010-05-21 14:38:37 +0100
commit94c1614164b720b2c06e7252688795137e16cd70 (patch)
treefd28dae1edee62ecc5ef2dc9c6e2b56b94eecc3b /cogl/cogl-framebuffer.c
parent6696b4ff4331b49128bbd933cb72b72d5b10ba20 (diff)
parent676c8a5fd4e0a9126a1a735f9e89513e5614a838 (diff)
downloadcogl-94c1614164b720b2c06e7252688795137e16cd70.tar.gz
Merge branch 'wip/framebuffer-bits'
* wip/framebuffer-bits: Implement accessors for the color bits in a framebuffer
Diffstat (limited to 'cogl/cogl-framebuffer.c')
-rw-r--r--cogl/cogl-framebuffer.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index 3f01ca58..21fffd61 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -130,6 +130,8 @@ _cogl_framebuffer_init (CoglFramebuffer *framebuffer,
framebuffer->modelview_stack = _cogl_matrix_stack_new ();
framebuffer->projection_stack = _cogl_matrix_stack_new ();
+ framebuffer->dirty_bitmasks = TRUE;
+
/* Initialise the clip stack */
_cogl_clip_state_init (&framebuffer->clip_state);
}
@@ -248,6 +250,20 @@ _cogl_framebuffer_get_projection_stack (CoglHandle handle)
return framebuffer->projection_stack;
}
+static inline void
+_cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
+{
+ if (G_LIKELY (!framebuffer->dirty_bitmasks))
+ return;
+
+ GE( glGetIntegerv (GL_RED_BITS, &framebuffer->red_bits) );
+ GE( glGetIntegerv (GL_GREEN_BITS, &framebuffer->green_bits) );
+ GE( glGetIntegerv (GL_BLUE_BITS, &framebuffer->blue_bits) );
+ GE( glGetIntegerv (GL_ALPHA_BITS, &framebuffer->alpha_bits) );
+
+ framebuffer->dirty_bitmasks = FALSE;
+}
+
static gboolean
try_creating_fbo (CoglOffscreen *offscreen,
TryFBOFlags flags,
@@ -555,6 +571,8 @@ _cogl_set_framebuffer_real (CoglFramebuffer *framebuffer)
_cogl_matrix_stack_dirty (framebuffer->modelview_stack);
_cogl_matrix_stack_dirty (framebuffer->projection_stack);
_cogl_clip_state_dirty (&framebuffer->clip_state);
+
+ _cogl_framebuffer_init_bits (framebuffer);
}
void
@@ -710,3 +728,42 @@ _cogl_framebuffer_flush_state (CoglHandle handle,
COGL_MATRIX_PROJECTION);
}
+int
+cogl_framebuffer_get_red_bits (CoglHandle framebuffer)
+{
+ CoglFramebuffer *fb = COGL_FRAMEBUFFER (framebuffer);
+
+ _cogl_framebuffer_init_bits (fb);
+
+ return fb->red_bits;
+}
+
+int
+cogl_framebuffer_get_green_bits (CoglHandle framebuffer)
+{
+ CoglFramebuffer *fb = COGL_FRAMEBUFFER (framebuffer);
+
+ _cogl_framebuffer_init_bits (fb);
+
+ return fb->green_bits;
+}
+
+int
+cogl_framebuffer_get_blue_bits (CoglHandle framebuffer)
+{
+ CoglFramebuffer *fb = COGL_FRAMEBUFFER (framebuffer);
+
+ _cogl_framebuffer_init_bits (fb);
+
+ return fb->blue_bits;
+}
+
+int
+cogl_framebuffer_get_alpha_bits (CoglHandle framebuffer)
+{
+ CoglFramebuffer *fb = COGL_FRAMEBUFFER (framebuffer);
+
+ _cogl_framebuffer_init_bits (fb);
+
+ return fb->alpha_bits;
+}