[Cogl] [1.12][master] Fix COGL build on Windows

Fan Chun-wei fanc999 at yahoo.com.tw
Wed Nov 21 21:14:48 PST 2012


Hi,

(sorry, if this message was double-sent, as I just sent it from my other 
mail account, which is not subscribed to the cogl-list)

Sorry for the absence from maintaining the COGL Visual C++ build files...:)

Anyways, first up is Neil's patch that fixes COGL builds on Windows in 
cogl-gles2-context.c,
due to the use of different calling conventions which
-Breaks the build on Visual C++ (MSVC is picky with calling convention 
inconsistencies)
-Cause a number of warnings that show up in MinGW builds.

Thank you for your time.

With blessings!
-------------- next part --------------
From 60077acf9e39d77f89fe7cca23958e6dd89c3662 Mon Sep 17 00:00:00 2001
From: Neil Roberts <neil at linux.intel.com>
Date: Tue, 17 Jul 2012 15:32:08 +0100
Subject: [PATCH] cogl-gles2-context: Cast func pointers to void* when filling
vtable
 
The function prototypes for the GL functions in CoglContext have the
GLAPIENTRY attribute which on Windows makes them use the stdcall
calling convention. The function pointers exposed from cogl-gles2.h
don't have GLAPIENTRY so they end up having a different calling
convention on Windows. When Cogl is compiled there it ends up giving a
lot of warnings because it assigns a pointer to an incompatible
function type.
 
We probably don't want to make the functions exposed in cogl-gles2.h
use the stdcall calling convention because we control that API so
there is no need to introduce a second calling convention. The GLES2
context support currently isn't going to work on Windows anyway
because there is no EGL or GLES2 implementation.
 
Eventually if we make the Cogl GLES2 context virtualized on top of
Cogl then we will provide our own implementations of all these
functions so we can easily keep the C calling convention even on
Windows.
 
Until then to avoid the warnings on Windows we can just cast the
function pointers temporarily to (void*) when filling in the vtable.

This will also fix the build on Windows using Visual Studio, as it is
more picky on calling convention mismatches.
---
cogl/cogl-gles2-context.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
 
diff --git a/cogl/cogl-gles2-context.c b/cogl/cogl-gles2-context.c
index 7d3f9d3..860c1cf 100644
--- a/cogl/cogl-gles2-context.c
+++ b/cogl/cogl-gles2-context.c
@@ -270,7 +270,7 @@ cogl_gles2_context_new (CoglContext *ctx, GError **error)
extension_suffixes, extension_names)
#define COGL_EXT_FUNCTION(ret, name, args) \
- gles2_ctx->vtable->name = ctx->name;
+ gles2_ctx->vtable->name = (void *) ctx->name;
#define COGL_EXT_END()
@@ -280,10 +280,14 @@ cogl_gles2_context_new (CoglContext *ctx, GError **error)
#undef COGL_EXT_FUNCTION
#undef COGL_EXT_END
- gles2_ctx->vtable->glBindFramebuffer = gl_bind_framebuffer_wrapper;
- gles2_ctx->vtable->glReadPixels = gl_read_pixels_wrapper;
- gles2_ctx->vtable->glCopyTexImage2D = gl_copy_tex_image_2d_wrapper;
- gles2_ctx->vtable->glCopyTexSubImage2D = gl_copy_tex_sub_image_2d_wrapper;
+ gles2_ctx->vtable->glBindFramebuffer =
+ (void *) gl_bind_framebuffer_wrapper;
+ gles2_ctx->vtable->glReadPixels =
+ (void *) gl_read_pixels_wrapper;
+ gles2_ctx->vtable->glCopyTexImage2D =
+ (void *) gl_copy_tex_image_2d_wrapper;
+ gles2_ctx->vtable->glCopyTexSubImage2D =
+ (void *) gl_copy_tex_sub_image_2d_wrapper;
return _cogl_gles2_context_object_new (gles2_ctx);
}
-- 
1.7.11.3.g3c3efa5



More information about the Cogl mailing list