diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 03e5302ea..a1f88acfe 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -61,6 +61,7 @@ #include #include #include +#include #endif /* Available video drivers */ @@ -468,6 +469,28 @@ int SDL_VideoInit(const char *driver_name) if (!driver_name) { driver_name = SDL_GetHint(SDL_HINT_VIDEODRIVER); } +#ifdef __LINUX__ + if (!driver_name) { + /* See if it looks like we need X11 */ + SDL_bool force_x11 = SDL_FALSE; + void *global_symbols = dlopen(NULL, RTLD_LOCAL|RTLD_NOW); + + /* Use linked libraries to detect what quirks we are likely to need */ + if (global_symbols != NULL) { + if (dlsym(global_symbols, "glxewInit") != NULL) { /* GLEW (e.g. Frogatto, SLUDGE) */ + force_x11 = SDL_TRUE; + } else if (dlsym(global_symbols, "cgGLEnableProgramProfiles") != NULL) { /* NVIDIA Cg (e.g. Awesomenauts, Braid) */ + force_x11 = SDL_TRUE; + } else if (dlsym(global_symbols, "_Z7ssgInitv") != NULL) { /* ::ssgInit(void) in plib (e.g. crrcsim) */ + force_x11 = SDL_TRUE; + } + dlclose(global_symbols); + } + if (force_x11) { + driver_name = "x11"; + } + } +#endif if (driver_name && *driver_name != 0) { const char *driver_attempt = driver_name; while (driver_attempt && *driver_attempt != 0 && !video) {