[Android] Fall back to using dlsym on ourselves to pull in OpenGL Functions 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...

This commit is contained in:
Ryan Houdek 2013-08-15 18:07:03 +00:00
parent 863fb9f95b
commit 06620ff364

View File

@ -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;
@ -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);
}
}