summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2012-12-13 15:55:05 +0000
committerRobert Bragg <robert@linux.intel.com>2013-01-22 17:48:19 +0000
commit988486ac7d6660997410fa100a7c444b65666106 (patch)
tree43ffc32d32e46babc1753f64d5ad35c29556f560
parent520ccba49d4d5124da0b2264026fe9edb9605e5c (diff)
downloadcogl-988486ac7d6660997410fa100a7c444b65666106.tar.gz
framebuffer: Support the GL_RED texture workaround when querying bits
When a component-alpha texture is made using a GL3 context a GL_RED texture is actually used and a swizzle is set up to hide it. However if a framebuffer is then bound to that texture then when the bits are queried this workaround will leak out of the API. To fix this it now detects the situation and reports the number of red bits as the number of alpha bits. Reviewed-by: Robert Bragg <robert@linux.intel.com> (cherry picked from commit 425cfb2675912a2cbcaaaeed7c2196d563948222)
-rw-r--r--cogl/driver/gl/cogl-framebuffer-gl.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/driver/gl/cogl-framebuffer-gl.c
index 4cecf676..b6f58ba9 100644
--- a/cogl/driver/gl/cogl-framebuffer-gl.c
+++ b/cogl/driver/gl/cogl-framebuffer-gl.c
@@ -948,6 +948,16 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
GE( ctx, glGetIntegerv (GL_STENCIL_BITS, &framebuffer->bits.stencil) );
}
+ /* If we don't have alpha textures then the alpha bits are actually
+ * stored in the red component */
+ if ((ctx->private_feature_flags &
+ COGL_PRIVATE_FEATURE_ALPHA_TEXTURES) == 0 &&
+ framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN &&
+ framebuffer->format == COGL_PIXEL_FORMAT_A_8)
+ {
+ framebuffer->bits.alpha = framebuffer->bits.red;
+ framebuffer->bits.red = 0;
+ }
COGL_NOTE (OFFSCREEN,
"RGBA/D/S Bits for framebuffer[%p, %s]: %d, %d, %d, %d, %d, %d",