diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLFunctions.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GLFunctions.cpp index 2759fd82ff..e174a1e64d 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLFunctions.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLFunctions.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include "GLFunctions.h" #include "Log.h" +#include #ifdef USE_GLES3 PFNGLMAPBUFFERPROC glMapBuffer; PFNGLMAPBUFFERRANGEPROC glMapBufferRange; @@ -43,27 +44,35 @@ PFNGLGENQUERIESPROC glGenQueries; #endif namespace GLFunc { + void *self; void LoadFunction(const char *name, void **func) { #ifdef USE_GLES3 *func = (void*)eglGetProcAddress(name); if (*func == NULL) { - ERROR_LOG(VIDEO, "Couldn't load function %s", name); - exit(0); + // Fall back to trying dlsym + if (self) // Just in case dlopen fails + *func = dlsym(self, name); + if (*func == NULL) + { + ERROR_LOG(VIDEO, "Couldn't load function %s", name); + exit(0); + } } #endif } void Init() { + self = dlopen(NULL, RTLD_LAZY); LoadFunction("glBeginQuery", (void**)&glBeginQuery); LoadFunction("glEndQuery", (void**)&glEndQuery); LoadFunction("glGetQueryObjectuiv", (void**)&glGetQueryObjectuiv); LoadFunction("glDeleteQueries", (void**)&glDeleteQueries); LoadFunction("glGenQueries", (void**)&glGenQueries); { - LoadFunction("glMapBuffer", (void**)&glMapBuffer); + LoadFunction("glMapBufferOES", (void**)&glMapBuffer); LoadFunction("glUnmapBuffer", (void**)&glUnmapBuffer); LoadFunction("glMapBufferRange", (void**)&glMapBufferRange); LoadFunction("glBindBufferRange", (void**)&glBindBufferRange); @@ -93,5 +102,6 @@ namespace GLFunc LoadFunction("glGetUniformBlockIndex", (void**)&glGetUniformBlockIndex); LoadFunction("glUniformBlockBinding", (void**)&glUniformBlockBinding); + dlclose(self); } }