diff --git a/README.md b/README.md index 453c9ed..7530a9d 100644 --- a/README.md +++ b/README.md @@ -62,11 +62,16 @@ It should be as easy as replacing: #include #include #include + #include + #include + #include // for WGL with: #include #include + #include + #include As long as epoxy's headers appear first, you should be ready to go. Additionally, some new helpers become available, so you don't have to diff --git a/include/epoxy/common.h b/include/epoxy/common.h new file mode 100644 index 0000000..e00a011 --- /dev/null +++ b/include/epoxy/common.h @@ -0,0 +1,62 @@ +/* + * Copyright © 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +/** @file common.h + * + * Provides basic definitions for Epoxy. Included by all other Epoxy files. + */ + +#ifndef EPOXY_COMMON_H +#define EPOXY_COMMON_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined _WIN32 || defined __CYGWIN__ + #ifdef EPOXY_EXPORTS + #ifdef __GNUC__ + #define EPOXY_IMPORTEXPORT __attribute__ ((dllexport)) + #else + #define EPOXY_IMPORTEXPORT __declspec(dllexport) + #endif + #else + #ifdef __GNUC__ + #define EPOXY_IMPORTEXPORT __attribute__ ((dllimport)) + #else + #define EPOXY_IMPORTEXPORT __declspec(dllimport) + #endif + #endif +#else + #if __GNUC__ >= 4 + #define EPOXY_IMPORTEXPORT __attribute__ ((visibility ("default"))) + #else + #define EPOXY_IMPORTEXPORT + #endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* EPOXY_COMMON_H */ diff --git a/include/epoxy/egl.h b/include/epoxy/egl.h index bd02948..ae54929 100644 --- a/include/epoxy/egl.h +++ b/include/epoxy/egl.h @@ -30,12 +30,13 @@ #ifndef EPOXY_EGL_H #define EPOXY_EGL_H +#include +#include + #ifdef __cplusplus extern "C" { #endif -#include - #if defined(__egl_h_) || defined(__eglext_h_) #error epoxy/egl.h must be included before (or in place of) GL/egl.h #else @@ -45,8 +46,8 @@ extern "C" { #include "epoxy/egl_generated.h" -PUBLIC bool epoxy_has_egl_extension(EGLDisplay dpy, const char *extension); -PUBLIC int epoxy_egl_version(EGLDisplay dpy); +EPOXY_IMPORTEXPORT bool epoxy_has_egl_extension(EGLDisplay dpy, const char *extension); +EPOXY_IMPORTEXPORT int epoxy_egl_version(EGLDisplay dpy); #ifdef __cplusplus } /* extern "C" */ diff --git a/include/epoxy/gl.h b/include/epoxy/gl.h index 0be3a66..d150da4 100644 --- a/include/epoxy/gl.h +++ b/include/epoxy/gl.h @@ -30,12 +30,13 @@ #ifndef EPOXY_GL_H #define EPOXY_GL_H +#include +#include + #ifdef __cplusplus extern "C" { #endif -#include - #if defined(__gl_h_) || defined(__glext_h_) #error epoxy/gl.h must be included before (or in place of) GL/gl.h #else @@ -51,7 +52,6 @@ extern "C" { /* APIENTRY and GLAPIENTRY are not used on Linux or Mac. */ #define APIENTRY #define GLAPIENTRY -#define EPOXY_IMPORTEXPORT #define EPOXY_CALLSPEC #define GLAPI #define KHRONOS_APIENTRY @@ -70,10 +70,6 @@ extern "C" { #define EPOXY_CALLSPEC __stdcall #endif -#ifndef EPOXY_IMPORTEXPORT -#define EPOXY_IMPORTEXPORT __declspec(dllimport) -#endif - #ifndef GLAPI #define GLAPI extern #endif diff --git a/include/epoxy/glx.h b/include/epoxy/glx.h index 36fc617..5efe931 100644 --- a/include/epoxy/glx.h +++ b/include/epoxy/glx.h @@ -30,15 +30,15 @@ #ifndef EPOXY_GLX_H #define EPOXY_GLX_H -#ifdef __cplusplus -extern "C" { -#endif - #include #include #include #include +#ifdef __cplusplus +extern "C" { +#endif + #if defined(GLX_H) || defined(__glxext_h_) #error epoxy/glx.h must be included before (or in place of) GL/glx.h #else @@ -48,8 +48,8 @@ extern "C" { #include "epoxy/glx_generated.h" -bool epoxy_has_glx_extension(Display *dpy, int screen, const char *extension); -int epoxy_glx_version(Display *dpy, int screen); +EPOXY_IMPORTEXPORT bool epoxy_has_glx_extension(Display *dpy, int screen, const char *extension); +EPOXY_IMPORTEXPORT int epoxy_glx_version(Display *dpy, int screen); #ifdef __cplusplus } /* extern "C" */ diff --git a/include/epoxy/wgl.h b/include/epoxy/wgl.h index fdd7b4f..9ab74f8 100644 --- a/include/epoxy/wgl.h +++ b/include/epoxy/wgl.h @@ -30,13 +30,14 @@ #ifndef EPOXY_WGL_H #define EPOXY_WGL_H +#include +#include +#include + #ifdef __cplusplus extern "C" { #endif -#include -#include - #undef wglUseFontBitmaps #undef wglUseFontOutlines diff --git a/src/Makefile.am b/src/Makefile.am index 49c3507..9c3229b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,6 +29,7 @@ AM_CFLAGS = \ $(VISIBILITY_CFLAGS) \ $(X11_CFLAGS) \ $(EGL_CFLAGS) \ + -DEPOXY_EXPORTS \ $() epoxyincludedir = $(includedir)/epoxy diff --git a/src/Makefile.vc b/src/Makefile.vc index a111bab..7b71f13 100644 --- a/src/Makefile.vc +++ b/src/Makefile.vc @@ -46,7 +46,7 @@ EPOXY_DLL_BASENAME = $(EPOXY_BASENAME)-vs$(VSVER) all: $(EPOXY_DLL_BASENAME).dll $(EPOXY_DLL_BASENAME).dll: ../$(GL_GEN_HEADER) ../$(WGL_GEN_HEADER) ../$(EGL_GEN_HEADER) $(GENERATED_GL_SOURCE) $(GENERATED_WGL_SOURCE) $(GENERATED_EGL_SOURCE) $(EPOXY_C_SRC) $(EPOXY_WGL_C_SRC) $(EPOXY_EGL_C_SRC) - $(CC) $(CFLAGS_ADD) $(CFLAGS_C99_COMPAT) $(EPOXY_C_SRC) $(EPOXY_WGL_C_SRC) $(EPOXY_EGL_C_SRC) $(GENERATED_GL_SOURCE) $(GENERATED_WGL_SOURCE) $(GENERATED_EGL_SOURCE) /I c:\opt\Imagination-3_5\PowerVR_Graphics\PowerVR_SDK\SDK_3.5\Builds\Include \ + $(CC) $(CFLAGS_ADD) $(CFLAGS_C99_COMPAT) $(EPOXY_C_SRC) $(EPOXY_WGL_C_SRC) $(EPOXY_EGL_C_SRC) $(GENERATED_GL_SOURCE) $(GENERATED_WGL_SOURCE) $(GENERATED_EGL_SOURCE) /DEPOXY_EXPORTS \ /link /DLL /DEBUG $(EXTRA_LDFLAGS) /pdb:$(EPOXY_DLL_BASENAME).pdb /out:$@ /implib:$(EPOXY_BASENAME).lib @if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2 diff --git a/src/dispatch_common.c b/src/dispatch_common.c index 013027f..f6fbd9f 100644 --- a/src/dispatch_common.c +++ b/src/dispatch_common.c @@ -265,7 +265,7 @@ do_dlsym(void **handle, const char *lib_name, const char *name, return result; } -PUBLIC bool +EPOXY_IMPORTEXPORT bool epoxy_is_desktop_gl(void) { const char *es_prefix = "OpenGL ES"; @@ -329,7 +329,7 @@ epoxy_internal_gl_version(int error_version) return 10 * major + minor; } -PUBLIC int +EPOXY_IMPORTEXPORT int epoxy_gl_version(void) { return epoxy_internal_gl_version(0); @@ -452,7 +452,7 @@ epoxy_current_context_is_glx(void) * \sa epoxy_has_egl_extension() * \sa epoxy_has_glx_extension() */ -PUBLIC bool +EPOXY_IMPORTEXPORT bool epoxy_has_gl_extension(const char *ext) { return epoxy_internal_has_gl_extension(ext, false); @@ -703,5 +703,5 @@ WRAPPER(epoxy_glEnd)(void) #endif } -PUBLIC PFNGLBEGINPROC epoxy_glBegin = epoxy_glBegin_wrapped; -PUBLIC PFNGLENDPROC epoxy_glEnd = epoxy_glEnd_wrapped; +EPOXY_IMPORTEXPORT PFNGLBEGINPROC epoxy_glBegin = epoxy_glBegin_wrapped; +EPOXY_IMPORTEXPORT PFNGLENDPROC epoxy_glEnd = epoxy_glEnd_wrapped; diff --git a/src/dispatch_common.h b/src/dispatch_common.h index 161fe07..c32815a 100644 --- a/src/dispatch_common.h +++ b/src/dispatch_common.h @@ -27,32 +27,18 @@ #define PLATFORM_HAS_EGL 1 #define PLATFORM_HAS_GLX 0 #define PLATFORM_HAS_WGL 1 -#define EPOXY_IMPORTEXPORT __declspec(dllexport) #elif defined(__APPLE__) #define PLATFORM_HAS_EGL 0 #define PLATFORM_HAS_GLX 0 #define PLATFORM_HAS_WGL 0 -#define EPOXY_IMPORTEXPORT #elif defined(ANDROID) #define PLATFORM_HAS_EGL 1 #define PLATFORM_HAS_GLX 0 #define PLATFORM_HAS_WGL 0 -#define EPOXY_IMPORTEXPORT #else #define PLATFORM_HAS_EGL 1 #define PLATFORM_HAS_GLX 1 #define PLATFORM_HAS_WGL 0 -#define EPOXY_IMPORTEXPORT -#endif - -#ifndef PUBLIC -# ifdef _WIN32 -# define PUBLIC __declspec(dllexport) -# elif (defined(__GNUC__) && __GNUC__ >= 4) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) -# define PUBLIC __attribute__((visibility("default"))) -# else -# define PUBLIC -# endif #endif #if PLATFORM_HAS_WGL diff --git a/src/dispatch_egl.c b/src/dispatch_egl.c index 9649ba4..a9c5e24 100644 --- a/src/dispatch_egl.c +++ b/src/dispatch_egl.c @@ -38,7 +38,7 @@ epoxy_conservative_egl_version(void) return epoxy_egl_version(dpy); } -PUBLIC int +EPOXY_IMPORTEXPORT int epoxy_egl_version(EGLDisplay dpy) { int major, minor; @@ -62,7 +62,7 @@ epoxy_conservative_has_egl_extension(const char *ext) return epoxy_has_egl_extension(dpy, ext); } -PUBLIC bool +EPOXY_IMPORTEXPORT bool epoxy_has_egl_extension(EGLDisplay dpy, const char *ext) { return epoxy_extension_in_string(eglQueryString(dpy, EGL_EXTENSIONS), ext); diff --git a/src/dispatch_glx.c b/src/dispatch_glx.c index 78e61c2..f1ff447 100644 --- a/src/dispatch_glx.c +++ b/src/dispatch_glx.c @@ -47,7 +47,7 @@ epoxy_conservative_glx_version(void) return epoxy_glx_version(dpy, screen); } -PUBLIC int +EPOXY_IMPORTEXPORT int epoxy_glx_version(Display *dpy, int screen) { int server_major, server_minor; @@ -92,7 +92,7 @@ epoxy_conservative_has_glx_extension(const char *ext) return epoxy_has_glx_extension(dpy, screen, ext); } -PUBLIC bool +EPOXY_IMPORTEXPORT bool epoxy_has_glx_extension(Display *dpy, int screen, const char *ext) { /* No, you can't just use glXGetClientString or diff --git a/src/dispatch_wgl.c b/src/dispatch_wgl.c index bfe9bb1..64257a1 100644 --- a/src/dispatch_wgl.c +++ b/src/dispatch_wgl.c @@ -46,7 +46,7 @@ epoxy_conservative_has_wgl_extension(const char *ext) return epoxy_has_wgl_extension(hdc, ext); } -PUBLIC bool +EPOXY_IMPORTEXPORT bool epoxy_has_wgl_extension(HDC hdc, const char *ext) { PFNWGLGETEXTENSIONSSTRINGARBPROC getext; @@ -72,7 +72,7 @@ epoxy_has_wgl_extension(HDC hdc, const char *ext) * table per context and reuse it when the context is made current * again. */ -PUBLIC void +EPOXY_IMPORTEXPORT void epoxy_handle_external_wglMakeCurrent(void) { if (!first_context_current) { @@ -190,7 +190,7 @@ WRAPPER(epoxy_wglMakeAssociatedContextCurrentAMD)(HGLRC hglrc) return ret; } -PUBLIC PFNWGLMAKECURRENTPROC epoxy_wglMakeCurrent = epoxy_wglMakeCurrent_wrapped; -PUBLIC PFNWGLMAKECONTEXTCURRENTEXTPROC epoxy_wglMakeContextCurrentEXT = epoxy_wglMakeContextCurrentEXT_wrapped; -PUBLIC PFNWGLMAKECONTEXTCURRENTARBPROC epoxy_wglMakeContextCurrentARB = epoxy_wglMakeContextCurrentARB_wrapped; -PUBLIC PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC epoxy_wglMakeAssociatedContextCurrentEXT = epoxy_wglMakeAssociatedContextCurrentAMD_wrapped; +EPOXY_IMPORTEXPORT PFNWGLMAKECURRENTPROC epoxy_wglMakeCurrent = epoxy_wglMakeCurrent_wrapped; +EPOXY_IMPORTEXPORT PFNWGLMAKECONTEXTCURRENTEXTPROC epoxy_wglMakeContextCurrentEXT = epoxy_wglMakeContextCurrentEXT_wrapped; +EPOXY_IMPORTEXPORT PFNWGLMAKECONTEXTCURRENTARBPROC epoxy_wglMakeContextCurrentARB = epoxy_wglMakeContextCurrentARB_wrapped; +EPOXY_IMPORTEXPORT PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC epoxy_wglMakeAssociatedContextCurrentEXT = epoxy_wglMakeAssociatedContextCurrentAMD_wrapped; diff --git a/src/gen_dispatch.py b/src/gen_dispatch.py index e8f55b8..0d72010 100755 --- a/src/gen_dispatch.py +++ b/src/gen_dispatch.py @@ -77,7 +77,7 @@ class GLFunction(object): self.public = '' else: self.wrapped_name = name - self.public = 'PUBLIC ' + self.public = 'EPOXY_IMPORTEXPORT ' # This is the string of C code for passing through the # arguments to the function.