From 340c83b990e1af0da0a1ffeb27935e6ac85532f2 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 14 Jul 2001 19:11:26 +0000 Subject: [PATCH] SDL GL dynamic loading fix for OpenBSD --- src/video/x11/SDL_x11gl.c | 13 ++++++++++++- src/video/x11/SDL_x11gl_c.h | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/video/x11/SDL_x11gl.c b/src/video/x11/SDL_x11gl.c index 13cba90f3..520d299e5 100644 --- a/src/video/x11/SDL_x11gl.c +++ b/src/video/x11/SDL_x11gl.c @@ -393,7 +393,9 @@ int X11_GL_LoadLibrary(_THIS, const char* path) 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 @@ fprintf(stderr, "glXGetProcAddress returned %p and dlsym returned %p for %s\n", 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 */ diff --git a/src/video/x11/SDL_x11gl_c.h b/src/video/x11/SDL_x11gl_c.h index ffec476e8..338610e90 100644 --- a/src/video/x11/SDL_x11gl_c.h +++ b/src/video/x11/SDL_x11gl_c.h @@ -28,6 +28,9 @@ static char rcsid = #ifdef HAVE_OPENGL #include #include +#if defined(__OpenBSD__) && !defined(__ELF__) +#define dlsym(x,y) dlsym(x, "_" y) +#endif #endif #include "SDL_sysvideo.h"