SDL GL dynamic loading fix for OpenBSD
authorSam Lantinga <slouken@lokigames.com>
Sat, 14 Jul 2001 19:11:26 +0000
changeset 110 7edee9f0f2cc
parent 109 5a9c36a45db1
child 111 53e3d8ba4321
SDL GL dynamic loading fix for OpenBSD
src/video/x11/SDL_x11gl.c
src/video/x11/SDL_x11gl_c.h
--- a/src/video/x11/SDL_x11gl.c	Sat Jul 14 19:10:06 2001 +0000
+++ b/src/video/x11/SDL_x11gl.c	Sat Jul 14 19:11:26 2001 +0000
@@ -393,7 +393,9 @@
 
 void *X11_GL_GetProcAddress(_THIS, const char* proc)
 {
+	static char procname[1024];
 	void* handle;
+	void* retval;
 	
 	handle = this->gl_config.dll_handle;
 #if 0 /* This doesn't work correctly yet */
@@ -407,7 +409,16 @@
         return this->gl_data->glXGetProcAddress(proc);
 	}
 #endif
-	return dlsym(handle, proc);
+#if defined(__OpenBSD__) && !defined(__ELF__)
+#undef dlsym(x,y);
+#endif
+	retval = dlsym(handle, proc);
+	if (!retval && strlen(proc) <= 1022) {
+		procname[0] = "_";
+		strcpy(procname + 1, proc);
+		retval = dlsym(handle, procname);
+	}
+	return retval;
 }
 
 #endif /* HAVE_OPENGL */
--- a/src/video/x11/SDL_x11gl_c.h	Sat Jul 14 19:10:06 2001 +0000
+++ b/src/video/x11/SDL_x11gl_c.h	Sat Jul 14 19:11:26 2001 +0000
@@ -28,6 +28,9 @@
 #ifdef HAVE_OPENGL
 #include <GL/glx.h>
 #include <dlfcn.h>
+#if defined(__OpenBSD__) && !defined(__ELF__)
+#define dlsym(x,y) dlsym(x, "_" y)
+#endif
 #endif
 #include "SDL_sysvideo.h"