cogl: Introduce the GE_RET() debug macro
authorDamien Lespiau <damien.lespiau@intel.com>
Mon, 11 Jan 2010 00:15:25 +0000 (00:15 +0000)
committerDamien Lespiau <damien.lespiau@intel.com>
Mon, 8 Feb 2010 17:14:49 +0000 (17:14 +0000)
Some GL functions have a return value that the GE() macro is not able to
handle. Let's define a new Ge_RET() macro which will be able to handle
functions such as glMapBuffer().

While at it, removed the unused variadic dots to the GE() macro.

clutter/cogl/cogl/cogl-internal.h

index f38107e..2645f7e 100644 (file)
@@ -62,7 +62,7 @@ typedef struct _CoglBoxedValue
 
 const gchar *cogl_gl_error_to_string (GLenum error_code);
 
-#define GE(x...)                        G_STMT_START {  \
+#define GE(x)                           G_STMT_START {  \
   GLenum __err;                                         \
   (x);                                                  \
   while ((__err = glGetError ()) != GL_NO_ERROR)        \
@@ -73,9 +73,21 @@ const gchar *cogl_gl_error_to_string (GLenum error_code);
                  cogl_gl_error_to_string (__err));      \
     }                                   } G_STMT_END
 
+#define GE_RET(ret, x)                  G_STMT_START {  \
+  GLenum __err;                                         \
+  ret = (x);                                            \
+  while ((__err = glGetError ()) != GL_NO_ERROR)        \
+    {                                                   \
+      g_warning ("%s: GL error (%d): %s\n",             \
+                 G_STRLOC,                              \
+                 __err,                                 \
+                 cogl_gl_error_to_string (__err));      \
+    }                                   } G_STMT_END
+
 #else /* !COGL_GL_DEBUG */
 
 #define GE(x) (x)
+#define GE_RET(ret, x)  (ret = (x))
 
 #endif /* COGL_GL_DEBUG */