<commit_before>#include <X11/Xlib.h>
#include "gl.h"

typedef void *GLXContext;

typedef void *(*glXChooseVisual_PTR)(void *, int, int *);
typedef GLXContext *(*glXCreateContext_PTR)(Display *, void *, GLXContext, Bool);
typedef Bool (*glXMakeCurrent_PTR)(Display *, int, GLXContext);
typedef void (*glXSwapBuffers_PTR)(Display *, int);

void *glXChooseVisual(void *display, int screen, int *attributes) {
    LOAD_GLES(glXChooseVisual);
    return gles_glXChooseVisual(display, screen, attributes);
}

GLXContext *glXCreateContext(Display *display,
                             void *visual,
                             GLXContext shareList,
                             Bool isDirect) {
    LOAD_GLES(glXCreateContext);
    return gles_glXCreateContext(display, visual, shareList, isDirect);
}

Bool glXMakeCurrent(Display *display, int drawable, GLXContext context) {
    LOAD_GLES(glXMakeCurrent);
    return gles_glXMakeCurrent(display, drawable, context);
}

void glXSwapBuffers(Display *display, int drawable) {
    LOAD_GLES(glXSwapBuffers);
    gles_glXSwapBuffers(display, drawable);
}

void glXWaitX() {}<commit_msg>improve glx wrapper<commit_after>#include <X11/Xlib.h>
#include "gl.h"
#include "../glx/glx.h"

typedef void *(*glXChooseVisual_PTR)(void *, int, int *);
typedef GLXContext (*glXCreateContext_PTR)(Display *, void *, GLXContext, Bool);
typedef Bool (*glXMakeCurrent_PTR)(Display *, int, GLXContext);
typedef void (*glXSwapBuffers_PTR)(Display *, int);
typedef void (*glXDestroyContext_PTR)(Display *, GLXContext);

XVisualInfo *glXChooseVisual(Display *display, int screen, int *attributes) {
    LOAD_GLES(glXChooseVisual);
    return gles_glXChooseVisual(display, screen, attributes);
}

GLXContext glXCreateContext(Display *display, XVisualInfo *visual, GLXContext shareList, Bool isDirect) {
    LOAD_GLES(glXCreateContext);
    return gles_glXCreateContext(display, visual, shareList, isDirect);
}

Bool glXMakeCurrent(Display *display, int drawable, GLXContext context) {
    LOAD_GLES(glXMakeCurrent);
    return gles_glXMakeCurrent(display, drawable, context);
}

void glXSwapBuffers(Display *display, int drawable) {
    LOAD_GLES(glXSwapBuffers);
    gles_glXSwapBuffers(display, drawable);
}

void glXDestroyContext(Display *dpy, GLXContext ctx) {
    LOAD_GLES(glXDestroyContext);
    glXDestroyContext(dpy, ctx);
}

const char *glXQueryExtensionsString(Display *display, int screen) {
    const char *extensions = {
        "GLX_ARB_create_context "
        "GLX_ARB_create_context_profile "
        "GLX_EXT_create_context_es2_profile "
    };
    return extensions;
}

const char *glXQueryServerString(Display *display, int screen, int name) {
    return "";
}

const char *glXGetClientString(Display *display, int name) {
    // TODO: return actual data here
    switch (name) {
        case GLX_VENDOR: break;
        case GLX_VERSION: break;
        case GLX_EXTENSIONS: break;
    }
    return "";
}

Bool glXQueryVersion(Display *display, int *major, int *minor) {
    // TODO: figure out which version we want to pretend to implement
    *major = 1;
    *minor = 4;
    return true;
}

Bool glXIsDirect() {
    return true;
}

void glXWaitX() {}
{'fraction_non_alphanumeric': 0.10836204196680238, 'fraction_numerical': 0.002192295646727216, 'mean_word_length': 4.431972789115647, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3695576', 'n_tokens_mistral': 1087, 'n_tokens_neox': 1034, 'n_words': 239}