[Cogl] [PATCH 1/2] Don't #ifdef the call to glDiscardFramebuffer

Neil Roberts neil at linux.intel.com
Mon Feb 11 09:36:48 PST 2013


When Cogl is compiled with support for both the GL and GLES drivers it
only includes the GL header and not the GLES header. That means in
that case it would not compile in the code for the
GL_EXT_discard_framebuffer extension even though it could be used on
the GLES driver. This patch makes it use the standard names for the
GL_COLOR, GL_STENCIL etc names instead of the _EXT suffixed names and
manually defines them if we are using the GLES headers. That way the
discard code can be used unconditionally.
---
 cogl/driver/gl/cogl-framebuffer-gl.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/driver/gl/cogl-framebuffer-gl.c
index d8a015d..abd3b4a 100644
--- a/cogl/driver/gl/cogl-framebuffer-gl.c
+++ b/cogl/driver/gl/cogl-framebuffer-gl.c
@@ -98,6 +98,17 @@
 #define GL_PACK_INVERT_MESA 0x8758
 #endif
 
+#ifndef GL_COLOR
+#define GL_COLOR 0x1800
+#endif
+#ifndef GL_DEPTH
+#define GL_DEPTH 0x1801
+#endif
+#ifndef GL_STENCIL
+#define GL_STENCIL 0x1802
+#endif
+
+
 static void
 _cogl_framebuffer_gl_flush_viewport_state (CoglFramebuffer *framebuffer)
 {
@@ -996,7 +1007,6 @@ void
 _cogl_framebuffer_gl_discard_buffers (CoglFramebuffer *framebuffer,
                                       unsigned long buffers)
 {
-#ifdef GL_EXT_discard_framebuffer
   CoglContext *ctx = framebuffer->context;
 
   if (ctx->glDiscardFramebuffer)
@@ -1007,11 +1017,11 @@ _cogl_framebuffer_gl_discard_buffers (CoglFramebuffer *framebuffer,
       if (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN)
         {
           if (buffers & COGL_BUFFER_BIT_COLOR)
-            attachments[i++] = GL_COLOR_EXT;
+            attachments[i++] = GL_COLOR;
           if (buffers & COGL_BUFFER_BIT_DEPTH)
-            attachments[i++] = GL_DEPTH_EXT;
+            attachments[i++] = GL_DEPTH;
           if (buffers & COGL_BUFFER_BIT_STENCIL)
-            attachments[i++] = GL_STENCIL_EXT;
+            attachments[i++] = GL_STENCIL;
         }
       else
         {
@@ -1025,7 +1035,6 @@ _cogl_framebuffer_gl_discard_buffers (CoglFramebuffer *framebuffer,
 
       GE (ctx, glDiscardFramebuffer (GL_FRAMEBUFFER, i, attachments));
     }
-#endif /* GL_EXT_discard_framebuffer */
 }
 
 void
-- 
1.7.11.3.g3c3efa5



More information about the Cogl mailing list