Project

General

Profile

kspfix.c

Work-around for glXChooseFBConfig bug - nand, 04/22/2016 10:58 PM

 
1
#define _GNU_SOURCE
2

    
3
#include <string.h>
4
#include <stdio.h>
5
#include <stdlib.h>
6
#include <dlfcn.h>
7
#include <GL/glx.h>
8

    
9
GLXFBConfig *glXChooseFBConfig(Display *dpy, int screen, const int *attrib_list, int *nelements)
10
{
11
    for (int *attr = (int *)attrib_list; *attr != None; attr += 2) {
12
        if (attr[0] == GLX_ALPHA_SIZE) {
13
            attr[1] = 0;
14
        }
15
    }
16

    
17
    typeof(glXChooseFBConfig) *old_fbconfig;
18
    old_fbconfig = dlsym(RTLD_NEXT, "glXChooseFBConfig");
19
    return (*old_fbconfig)(dpy, screen, attrib_list, nelements);
20
}
21

    
22
__GLXextFuncPtr glXGetProcAddressARB(const GLubyte *name)
23
{
24
    if (strcmp((const char *) name, "glXChooseFBConfig") == 0)
25
        return glXChooseFBConfig;
26

    
27
    typeof(glXGetProcAddressARB) *old_getproc;
28
    old_getproc = dlsym(RTLD_NEXT, "glXGetProcAddressARB");
29
    return (*old_getproc)(name);
30
}