Last active
June 7, 2016 19:09
-
-
Save haasn/7f2134a3e34378cff6782e5f63f8ea8d to your computer and use it in GitHub Desktop.
Work-around for Kerbal Space Program under 10-bit displays (or any Unity game, really)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compile as kspfix.so and load with LD_PRELOAD | |
#define _GNU_SOURCE | |
#include <string.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <dlfcn.h> | |
#include <GL/glx.h> | |
GLXFBConfig *glXChooseFBConfig(Display *dpy, int screen, const int *attrib_list, int *nelements) | |
{ | |
for (int *attr = (int *)attrib_list; *attr != None; attr += 2) { | |
if (attr[0] == GLX_ALPHA_SIZE) { | |
attr[1] = 0; | |
} | |
} | |
typeof(glXChooseFBConfig) *old_fbconfig; | |
old_fbconfig = dlsym(RTLD_NEXT, "glXChooseFBConfig"); | |
return (*old_fbconfig)(dpy, screen, attrib_list, nelements); | |
} | |
__GLXextFuncPtr glXGetProcAddressARB(const GLubyte *name) | |
{ | |
if (strcmp((const char *) name, "glXChooseFBConfig") == 0) | |
return glXChooseFBConfig; | |
typeof(glXGetProcAddressARB) *old_getproc; | |
old_getproc = dlsym(RTLD_NEXT, "glXGetProcAddressARB"); | |
return (*old_getproc)(name); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment