summaryrefslogtreecommitdiff
path: root/src/libEGL.c
blob: da858bcc1c60d07c47bf09ce36a3897bdb8e4f13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <dlfcn.h>
#include <EGL/egl.h>
#include <GLFW/glfw3.h>
#define GLFW_EXPOSE_NATIVE_X11
#include <GLFW/glfw3native.h>

struct ANativeWindow {
   GLFWwindow *glfw;
};

EGLDisplay
eglGetDisplay(EGLNativeDisplayType native_display)
{
   static EGLDisplay (*orig_eglGetDisplay)(EGLNativeDisplayType native_display);
   if (!orig_eglGetDisplay) orig_eglGetDisplay = dlsym(RTLD_NEXT, "eglGetDisplay");
   return orig_eglGetDisplay(glfwGetX11Display());
}

EGLSurface
eglCreateWindowSurface(EGLDisplay display, EGLConfig config, NativeWindowType native_window, EGLint const *attrib_list)
{
   static EGLSurface (*orig_eglCreateWindowSurface)(EGLDisplay display, EGLConfig config, NativeWindowType native_window, EGLint const *attrib_list);
   if (!orig_eglCreateWindowSurface) orig_eglCreateWindowSurface = dlsym(RTLD_NEXT, "eglCreateWindowSurface");
   struct ANativeWindow *win = (struct ANativeWindow*)native_window;
   return orig_eglCreateWindowSurface(display, config, glfwGetX11Window(win->glfw), attrib_list);
}