Browse Source

Fixed OpenGL ES function loading on some Android devices.

Martin Felis 10 years ago
parent
commit
f6448116cc
1 changed files with 16 additions and 1 deletions
  1. 16 1
      src/modules/graphics/opengl/OpenGL.cpp

+ 16 - 1
src/modules/graphics/opengl/OpenGL.cpp

@@ -40,6 +40,10 @@
 #include <SDL_syswm.h>
 #endif
 
+#ifdef LOVE_ANDROID
+#include <dlfcn.h>
+#endif
+
 namespace love
 {
 namespace graphics
@@ -47,6 +51,17 @@ namespace graphics
 namespace opengl
 {
 
+static void *LOVEGetProcAddress(const char *name)
+{
+#ifdef LOVE_ANDROID
+	void *proc = dlsym(RTLD_DEFAULT, name);
+	if (proc)
+		return proc;
+#endif
+
+	return SDL_GL_GetProcAddress(name);
+}
+
 OpenGL::OpenGL()
 	: stats()
 	, contextInitialized(false)
@@ -67,7 +82,7 @@ bool OpenGL::initContext()
 	if (contextInitialized)
 		return true;
 
-	if (!gladLoadGLLoader(SDL_GL_GetProcAddress))
+	if (!gladLoadGLLoader(LOVEGetProcAddress))
 		return false;
 
 	initOpenGLFunctions();