Use the appropriate symbols on __APPLE__

When building on macOS we don't have access to EGL, and GLX support is
conditional.

We should ensure we're using the appropriate paths depending on the
platform, and protect our use of macros to avoid undefined symbols.

Closes: #176
macos/v1.5.9
Emmanuele Bassi 7 years ago
parent 350a98a308
commit 8c3d371187
  1. 27
      src/dispatch_common.c

@ -173,26 +173,24 @@
#include "dispatch_common.h" #include "dispatch_common.h"
#ifdef __APPLE__ #if defined(__APPLE__)
#define GLX_LIB "/opt/X11/lib/libGL.1.dylib" #define GLX_LIB "/opt/X11/lib/libGL.1.dylib"
#define OPENGL_LIB "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL" #define OPENGL_LIB "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL"
#define GLES1_LIB "libGLESv1_CM.so"
#define GLES2_LIB "libGLESv2.so"
#elif defined(__ANDROID__) #elif defined(__ANDROID__)
#define GLX_LIB "libGLESv2.so" #define GLX_LIB "libGLESv2.so"
#else
#define GLVND_GLX_LIB "libGLX.so.1"
#define GLX_LIB "libGL.so.1"
#endif
#ifdef __ANDROID__
#define EGL_LIB "libEGL.so" #define EGL_LIB "libEGL.so"
#define GLES1_LIB "libGLESv1_CM.so" #define GLES1_LIB "libGLESv1_CM.so"
#define GLES2_LIB "libGLESv2.so" #define GLES2_LIB "libGLESv2.so"
#elif defined _WIN32 #elif defined(_WIN32)
#define EGL_LIB "libEGL.dll" #define EGL_LIB "libEGL.dll"
#define GLES1_LIB "libGLES_CM.dll" #define GLES1_LIB "libGLES_CM.dll"
#define GLES2_LIB "libGLESv2.dll" #define GLES2_LIB "libGLESv2.dll"
#define OPENGL_LIB "OPENGL32" #define OPENGL_LIB "OPENGL32"
#else #else
#define GLVND_GLX_LIB "libGLX.so.1"
#define GLX_LIB "libGL.so.1"
#define EGL_LIB "libEGL.so.1" #define EGL_LIB "libEGL.so.1"
#define GLES1_LIB "libGLESv1_CM.so.1" #define GLES1_LIB "libGLESv1_CM.so.1"
#define GLES2_LIB "libGLESv2.so.2" #define GLES2_LIB "libGLESv2.so.2"
@ -553,6 +551,7 @@ epoxy_internal_has_gl_extension(const char *ext, bool invalid_op_mode)
bool bool
epoxy_load_glx(bool exit_if_fails, bool load) epoxy_load_glx(bool exit_if_fails, bool load)
{ {
#ifdef PLATFORM_HAS_GLX
# ifdef GLVND_GLX_LIB # ifdef GLVND_GLX_LIB
/* prefer the glvnd library if it exists */ /* prefer the glvnd library if it exists */
if (!api.glx_handle) if (!api.glx_handle)
@ -560,16 +559,17 @@ epoxy_load_glx(bool exit_if_fails, bool load)
# endif # endif
if (!api.glx_handle) if (!api.glx_handle)
get_dlopen_handle(&api.glx_handle, GLX_LIB, exit_if_fails, load); get_dlopen_handle(&api.glx_handle, GLX_LIB, exit_if_fails, load);
#endif
return api.glx_handle != NULL; return api.glx_handle != NULL;
} }
void * void *
epoxy_conservative_glx_dlsym(const char *name, bool exit_if_fails) epoxy_conservative_glx_dlsym(const char *name, bool exit_if_fails)
{ {
#ifdef PLATFORM_HAS_GLX
if (epoxy_load_glx(exit_if_fails, exit_if_fails)) if (epoxy_load_glx(exit_if_fails, exit_if_fails))
return do_dlsym(&api.glx_handle, name, exit_if_fails); return do_dlsym(&api.glx_handle, name, exit_if_fails);
#endif
return NULL; return NULL;
} }
@ -636,15 +636,20 @@ epoxy_conservative_has_gl_extension(const char *ext)
bool bool
epoxy_load_egl(bool exit_if_fails, bool load) epoxy_load_egl(bool exit_if_fails, bool load)
{ {
#if PLATFORM_HAS_EGL
return get_dlopen_handle(&api.egl_handle, EGL_LIB, exit_if_fails, load); return get_dlopen_handle(&api.egl_handle, EGL_LIB, exit_if_fails, load);
#else
return false;
#endif
} }
void * void *
epoxy_conservative_egl_dlsym(const char *name, bool exit_if_fails) epoxy_conservative_egl_dlsym(const char *name, bool exit_if_fails)
{ {
#if PLATFORM_HAS_EGL
if (epoxy_load_egl(exit_if_fails, exit_if_fails)) if (epoxy_load_egl(exit_if_fails, exit_if_fails))
return do_dlsym(&api.egl_handle, name, exit_if_fails); return do_dlsym(&api.egl_handle, name, exit_if_fails);
#endif
return NULL; return NULL;
} }

Loading…
Cancel
Save