[cogl] cogl-gles2-context: Cast func pointers to void* when filling vtable



commit 5ac07c4de207f83247f143fd01acba1e6b975385
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Sat Nov 24 00:20:56 2012 +0800

    cogl-gles2-context: Cast func pointers to void* when filling
    vtable
    
    (Sorry, I had to re-apply Neil's patch as the original one somehow did
     not apply)
    
    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.
    
    Reviewed-by: Robert Bragg <robert linux intel com>

 cogl/cogl-gles2-context.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/cogl/cogl-gles2-context.c b/cogl/cogl-gles2-context.c
index fa580dd..5bc0cf4 100644
--- a/cogl/cogl-gles2-context.c
+++ b/cogl/cogl-gles2-context.c
@@ -1600,7 +1600,7 @@ cogl_gles2_context_new (CoglContext *ctx, CoglError **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()
 
@@ -1610,10 +1610,15 @@ cogl_gles2_context_new (CoglContext *ctx, CoglError **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;
+
   gles2_ctx->vtable->glCreateShader = gl_create_shader_wrapper;
   gles2_ctx->vtable->glDeleteShader = gl_delete_shader_wrapper;
   gles2_ctx->vtable->glCreateProgram = gl_create_program_wrapper;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]