Abstract selector of translator or host GL libs a bit more

This commit is contained in:
Simon Fels 2017-01-20 18:05:40 +01:00
commit 30c2186826
13 changed files with 130 additions and 57 deletions

View file

@ -20,9 +20,11 @@
#include <stdio.h>
#include <stdlib.h>
EGLDispatch s_egl;
namespace {
constexpr const char *egl_lib_env_var{"ANBOX_EGL_LIB"};
}
#define DEFAULT_EGL_LIB EMUGL_LIBNAME("EGL_translator")
EGLDispatch s_egl;
#define RENDER_EGL_LOAD_FIELD(return_type, function_name, signature) \
s_egl. function_name = (function_name ## _t) lib->findSymbol(#function_name);
@ -33,20 +35,24 @@ EGLDispatch s_egl;
if (!s_egl.function_name || !s_egl.eglGetProcAddress) \
RENDER_EGL_LOAD_FIELD(return_type, function_name, signature)
bool init_egl_dispatch()
{
const char *libName = getenv("ANDROID_EGL_LIB");
if (!libName) libName = DEFAULT_EGL_LIB;
bool init_egl_dispatch(const char *path) {
const char *libName = getenv(egl_lib_env_var);
if (!libName)
libName = path;
if (!libName)
return false;
char error[256];
emugl::SharedLibrary *lib = emugl::SharedLibrary::open(libName, error, sizeof(error));
if (!lib) {
printf("Failed to open %s: [%s]\n", libName, error);
return NULL;
return false;
}
LIST_RENDER_EGL_FUNCTIONS(RENDER_EGL_LOAD_FIELD)
LIST_RENDER_EGL_EXTENSIONS_FUNCTIONS(RENDER_EGL_LOAD_OPTIONAL_FIELD)
s_egl.initialized = true;
return true;
}