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