summaryrefslogtreecommitdiff
path: root/cogl/cogl-framebuffer.h
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2013-10-09 13:31:12 +0100
committerRobert Bragg <robert@linux.intel.com>2013-11-27 18:06:31 +0000
commit248a76f5eac7e5ae4fb45208577f9a55360812a7 (patch)
tree4a532be33254311a2a591501b263d4d4f5908a5c /cogl/cogl-framebuffer.h
parent71406438c5357eb4e0ef03e940c5456a536602a0 (diff)
downloadcogl-248a76f5eac7e5ae4fb45208577f9a55360812a7.tar.gz
Declare interface types as void and remove cast macros
This declares the interface types CoglFramebuffer, CoglBuffer, CoglTexture, CoglMetaTexture and CoglPrimitiveTexture as void when including the public cogl.h header so that users don't have to use lots of C type casts between instance types and interface types. This also removes all of the COGL_XYZ() type cast macros since they do nothing more than compile time type casting but it's less readable if you haven't seen that coding pattern before. Unlike with gobject based apis that use per-type macros for casting and performing runtime type checking we instead prefer to do our runtime type checking internally within the front-end public apis when objects are passed into Cogl. This greatly reduces the verbosity for users of the api and may help reduce the chance of excessive runtime type checking that can sometimes be a problem.
Diffstat (limited to 'cogl/cogl-framebuffer.h')
-rw-r--r--cogl/cogl-framebuffer.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/cogl/cogl-framebuffer.h b/cogl/cogl-framebuffer.h
index 650552b2..8cba5d6b 100644
--- a/cogl/cogl-framebuffer.h
+++ b/cogl/cogl-framebuffer.h
@@ -35,7 +35,15 @@
/* We forward declare the CoglFramebuffer type here to avoid some circular
* dependency issues with the following headers.
*/
+#ifdef __COGL_H_INSIDE__
+/* For the public C api we typedef interface types as void to avoid needing
+ * lots of casting in code and instead we will rely on runtime type checking
+ * for these objects. */
+typedef void CoglFramebuffer;
+#else
typedef struct _CoglFramebuffer CoglFramebuffer;
+#define COGL_FRAMEBUFFER(X) ((CoglFramebuffer *)(X))
+#endif
#include <cogl/cogl-pipeline.h>
#include <cogl/cogl-indices.h>
@@ -84,8 +92,6 @@ COGL_BEGIN_DECLS
* configuration.
*/
-#define COGL_FRAMEBUFFER(X) ((CoglFramebuffer *)(X))
-
/**
* cogl_framebuffer_allocate:
* @framebuffer: A #CoglFramebuffer