Adds support for Android.

This has been tested with both OpenGL and OpenGL ES on Android.
We can't use dlsym on Android to get all the function pointers since Android's libGLES* libraries are just shim libraries that pass everything through
to the real vendor specific libraries.

Due to this we must grab function pointers entirely through eglGetProcAddress instead of dlsym.
macos/v1.5.9
Ryan Houdek 11 years ago
parent 7422de5b4b
commit c791612b0a
  1. 32
      src/dispatch_common.c
  2. 5
      src/dispatch_common.h

@ -104,10 +104,22 @@
#ifdef __APPLE__ #ifdef __APPLE__
#define GLX_LIB "/opt/X11/lib/libGL.1.dylib" #define GLX_LIB "/opt/X11/lib/libGL.1.dylib"
#elif defined(ANDROID)
#define GLX_LIB "libGLESv2.so"
#else #else
#define GLX_LIB "libGL.so.1" #define GLX_LIB "libGL.so.1"
#endif #endif
#ifdef ANDROID
#define EGL_LIB "libEGL.so"
#define GLES1_LIB "libGLESv1_CM.so"
#define GLES2_LIB "libGLESv2.so"
#else
#define EGL_LIB "libEGL.so.1"
#define GLES1_LIB "libGLESv1_CM.so.1"
#define GLES2_LIB "libGLESv2.so.2"
#endif
struct api { struct api {
#ifndef _WIN32 #ifndef _WIN32
/** /**
@ -380,7 +392,7 @@ epoxy_current_context_is_glx(void)
return true; return true;
#if PLATFORM_HAS_EGL #if PLATFORM_HAS_EGL
sym = do_dlsym(&api.egl_handle, "libEGL.so.1", "eglGetCurrentContext", sym = do_dlsym(&api.egl_handle, EGL_LIB, "eglGetCurrentContext",
false); false);
if (sym && epoxy_egl_get_current_gl_context_api() != EGL_NONE) if (sym && epoxy_egl_get_current_gl_context_api() != EGL_NONE)
return false; return false;
@ -416,7 +428,7 @@ epoxy_conservative_has_gl_extension(const char *ext)
void * void *
epoxy_egl_dlsym(const char *name) epoxy_egl_dlsym(const char *name)
{ {
return do_dlsym(&api.egl_handle, "libEGL.so.1", name, true); return do_dlsym(&api.egl_handle, EGL_LIB, name, true);
} }
void * void *
@ -446,7 +458,7 @@ epoxy_gles1_dlsym(const char *name)
if (epoxy_current_context_is_glx()) { if (epoxy_current_context_is_glx()) {
return epoxy_get_proc_address(name); return epoxy_get_proc_address(name);
} else { } else {
return do_dlsym(&api.gles1_handle, "libGLESv1_CM.so.1", name, true); return do_dlsym(&api.gles1_handle, GLES1_LIB, name, true);
} }
} }
@ -456,7 +468,7 @@ epoxy_gles2_dlsym(const char *name)
if (epoxy_current_context_is_glx()) { if (epoxy_current_context_is_glx()) {
return epoxy_get_proc_address(name); return epoxy_get_proc_address(name);
} else { } else {
return do_dlsym(&api.gles2_handle, "libGLESv2.so.2", name, true); return do_dlsym(&api.gles2_handle, GLES2_LIB, name, true);
} }
} }
@ -476,7 +488,7 @@ epoxy_gles3_dlsym(const char *name)
if (epoxy_current_context_is_glx()) { if (epoxy_current_context_is_glx()) {
return epoxy_get_proc_address(name); return epoxy_get_proc_address(name);
} else { } else {
void *func = do_dlsym(&api.gles2_handle, "libGLESv2.so.2", name, false); void *func = do_dlsym(&api.gles2_handle, GLES2_LIB, name, false);
if (func) if (func)
return func; return func;
@ -494,6 +506,12 @@ epoxy_get_core_proc_address(const char *name, int core_version)
{ {
#ifdef _WIN32 #ifdef _WIN32
int core_symbol_support = 10; int core_symbol_support = 10;
#elif defined(ANDROID)
/**
* All symbols must be resolved through eglGetProcAddress
* on Android
*/
int core_symbol_support = 0;
#else #else
int core_symbol_support = 12; int core_symbol_support = 12;
#endif #endif
@ -564,7 +582,7 @@ epoxy_get_bootstrap_proc_address(const char *name)
* non-X11 ES2 context from loading a bunch of X11 junk). * non-X11 ES2 context from loading a bunch of X11 junk).
*/ */
#if PLATFORM_HAS_EGL #if PLATFORM_HAS_EGL
get_dlopen_handle(&api.egl_handle, "libEGL.so.1", false); get_dlopen_handle(&api.egl_handle, EGL_LIB, false);
if (api.egl_handle) { if (api.egl_handle) {
switch (epoxy_egl_get_current_gl_context_api()) { switch (epoxy_egl_get_current_gl_context_api()) {
case EGL_OPENGL_API: case EGL_OPENGL_API:
@ -575,7 +593,7 @@ epoxy_get_bootstrap_proc_address(const char *name)
* us. Try the GLES2 implementation first, and fall back * us. Try the GLES2 implementation first, and fall back
* to GLES1 otherwise. * to GLES1 otherwise.
*/ */
get_dlopen_handle(&api.gles2_handle, "libGLESv2.so.2", false); get_dlopen_handle(&api.gles2_handle, GLES2_LIB, false);
if (api.gles2_handle) if (api.gles2_handle)
return epoxy_gles2_dlsym(name); return epoxy_gles2_dlsym(name);
else else

@ -33,6 +33,11 @@
#define PLATFORM_HAS_GLX 1 #define PLATFORM_HAS_GLX 1
#define PLATFORM_HAS_WGL 0 #define PLATFORM_HAS_WGL 0
#define EPOXY_IMPORTEXPORT #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 #else
#define PLATFORM_HAS_EGL 1 #define PLATFORM_HAS_EGL 1
#define PLATFORM_HAS_GLX 1 #define PLATFORM_HAS_GLX 1

Loading…
Cancel
Save