Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Android] Fall back to using dlsym on ourselves to pull in OpenGL Fun…
…ctions when eglGetProcAddress fails. This fixes an issue on the Chromebook where I was forced to link to libGLESv2 and pull in the functions statically since eglGetProcAddress wouldn't return any GLESv3 functions. This also changes glMapBuffer to glMapBufferOES because glMapBuffer isn't actually part of the OpenGL ES 3 spec...
  • Loading branch information
Sonicadvance1 committed Aug 15, 2013
1 parent 863fb9f commit 06620ff
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions Source/Plugins/Plugin_VideoOGL/Src/GLFunctions.cpp
Expand Up @@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include "GLFunctions.h"
#include "Log.h"
#include <dlfcn.h>
#ifdef USE_GLES3
PFNGLMAPBUFFERPROC glMapBuffer;
PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -93,5 +102,6 @@ namespace GLFunc

LoadFunction("glGetUniformBlockIndex", (void**)&glGetUniformBlockIndex);
LoadFunction("glUniformBlockBinding", (void**)&glUniformBlockBinding);
dlclose(self);
}
}

0 comments on commit 06620ff

Please sign in to comment.