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