Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/PojavLauncher
Path: blob/v3_openjdk/app_pojavlauncher/src/main/jni/ctxbridges/egl_loader.c
2128 views
1
//
2
// Created by maks on 21.09.2022.
3
//
4
#include <stddef.h>
5
#include <stdlib.h>
6
#include <dlfcn.h>
7
#include "egl_loader.h"
8
#include "loader_dlopen.h"
9
10
EGLBoolean (*eglMakeCurrent_p) (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
11
EGLBoolean (*eglDestroyContext_p) (EGLDisplay dpy, EGLContext ctx);
12
EGLBoolean (*eglDestroySurface_p) (EGLDisplay dpy, EGLSurface surface);
13
EGLBoolean (*eglTerminate_p) (EGLDisplay dpy);
14
EGLBoolean (*eglReleaseThread_p) (void);
15
EGLContext (*eglGetCurrentContext_p) (void);
16
EGLDisplay (*eglGetDisplay_p) (NativeDisplayType display);
17
EGLBoolean (*eglInitialize_p) (EGLDisplay dpy, EGLint *major, EGLint *minor);
18
EGLBoolean (*eglChooseConfig_p) (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
19
EGLBoolean (*eglGetConfigAttrib_p) (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
20
EGLBoolean (*eglBindAPI_p) (EGLenum api);
21
EGLSurface (*eglCreatePbufferSurface_p) (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
22
EGLSurface (*eglCreateWindowSurface_p) (EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list);
23
EGLBoolean (*eglSwapBuffers_p) (EGLDisplay dpy, EGLSurface draw);
24
EGLint (*eglGetError_p) (void);
25
EGLContext (*eglCreateContext_p) (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list);
26
EGLBoolean (*eglSwapInterval_p) (EGLDisplay dpy, EGLint interval);
27
EGLSurface (*eglGetCurrentSurface_p) (EGLint readdraw);
28
EGLBoolean (*eglQuerySurface_p)( EGLDisplay display,
29
EGLSurface surface,
30
EGLint attribute,
31
EGLint * value);
32
__eglMustCastToProperFunctionPointerType (*eglGetProcAddress_p) (const char *procname);
33
34
bool dlsym_EGL() {
35
void* dl_handle = loader_dlopen(getenv("POJAVEXEC_EGL"),"libEGL.so", RTLD_LOCAL|RTLD_LAZY);
36
if(dl_handle == NULL) return false;
37
eglGetProcAddress_p = dlsym(dl_handle, "eglGetProcAddress");
38
if(eglGetProcAddress_p == NULL) {
39
printf("%s\n", dlerror());
40
return false;
41
}
42
eglBindAPI_p = (void*) eglGetProcAddress_p("eglBindAPI");
43
eglChooseConfig_p = (void*) eglGetProcAddress_p("eglChooseConfig");
44
eglCreateContext_p = (void*) eglGetProcAddress_p("eglCreateContext");
45
eglCreatePbufferSurface_p = (void*) eglGetProcAddress_p("eglCreatePbufferSurface");
46
eglCreateWindowSurface_p = (void*) eglGetProcAddress_p("eglCreateWindowSurface");
47
eglDestroyContext_p = (void*) eglGetProcAddress_p("eglDestroyContext");
48
eglDestroySurface_p = (void*) eglGetProcAddress_p("eglDestroySurface");
49
eglGetConfigAttrib_p = (void*) eglGetProcAddress_p("eglGetConfigAttrib");
50
eglGetCurrentContext_p = (void*) eglGetProcAddress_p("eglGetCurrentContext");
51
eglGetDisplay_p = (void*) eglGetProcAddress_p("eglGetDisplay");
52
eglGetError_p = (void*) eglGetProcAddress_p("eglGetError");
53
eglInitialize_p = (void*) eglGetProcAddress_p("eglInitialize");
54
eglMakeCurrent_p = (void*) eglGetProcAddress_p("eglMakeCurrent");
55
eglSwapBuffers_p = (void*) eglGetProcAddress_p("eglSwapBuffers");
56
eglReleaseThread_p = (void*) eglGetProcAddress_p("eglReleaseThread");
57
eglSwapInterval_p = (void*) eglGetProcAddress_p("eglSwapInterval");
58
eglTerminate_p = (void*) eglGetProcAddress_p("eglTerminate");
59
eglGetCurrentSurface_p = (void*) eglGetProcAddress_p("eglGetCurrentSurface");
60
eglQuerySurface_p = (void*) eglGetProcAddress_p("eglQuerySurface");
61
return true;
62
}
63
64