Path: blob/v3_openjdk/app_pojavlauncher/src/main/jni/ctxbridges/osmesa_loader.c
2128 views
//1// Created by maks on 21.09.2022.2//3#include <stdio.h>4#include <stdlib.h>5#include <dlfcn.h>6#include "loader_dlopen.h"7#include "osmesa_loader.h"89GLboolean (*OSMesaMakeCurrent_p) (OSMesaContext ctx, void *buffer, GLenum type,10GLsizei width, GLsizei height);11OSMesaContext (*OSMesaGetCurrentContext_p) (void);12OSMesaContext (*OSMesaCreateContext_p) (GLenum format, OSMesaContext sharelist);13void (*OSMesaDestroyContext_p) (OSMesaContext ctx);14void (*OSMesaPixelStore_p) ( GLint pname, GLint value );15GLubyte* (*glGetString_p) (GLenum name);16void (*glFinish_p) (void);17void (*glClearColor_p) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);18void (*glClear_p) (GLbitfield mask);19void (*glReadPixels_p) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * data);20void* (*OSMesaGetProcAddress_p)(const char* funcName);2122bool dlsym_OSMesa() {23void* dl_handle = loader_dlopen("libOSMesa.so.8", "libOSMesa.so", RTLD_LOCAL | RTLD_LAZY);24if(dl_handle == NULL) return false;25OSMesaGetProcAddress_p = dlsym(dl_handle, "OSMesaGetProcAddress");26if(OSMesaGetProcAddress_p == NULL) {27printf("%s\n", dlerror());28return false;29}30OSMesaMakeCurrent_p = OSMesaGetProcAddress_p("OSMesaMakeCurrent");31OSMesaGetCurrentContext_p = OSMesaGetProcAddress_p("OSMesaGetCurrentContext");32OSMesaCreateContext_p = OSMesaGetProcAddress_p("OSMesaCreateContext");33OSMesaDestroyContext_p = OSMesaGetProcAddress_p("OSMesaDestroyContext");34OSMesaPixelStore_p = OSMesaGetProcAddress_p("OSMesaPixelStore");35glGetString_p = OSMesaGetProcAddress_p("glGetString");36glClearColor_p = OSMesaGetProcAddress_p("glClearColor");37glClear_p = OSMesaGetProcAddress_p("glClear");38glFinish_p = OSMesaGetProcAddress_p("glFinish");39glReadPixels_p = OSMesaGetProcAddress_p("glReadPixels");40return true;41}4243