summaryrefslogtreecommitdiff
path: root/src/libEGL.c
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-02-27 13:42:15 +0200
committerJari Vetoniemi <mailroxas@gmail.com>2018-02-27 13:43:09 +0200
commit7be0f42f46ed3fa07ef8aa5003db453daa87e8a1 (patch)
tree60272e254c6738cf45becfc3d2f75dde98325314 /src/libEGL.c
parent61fdc3c23af1c842da8cd66673d5ce0ad5f1c6cf (diff)
Add libEGL shim
Diffstat (limited to 'src/libEGL.c')
-rw-r--r--src/libEGL.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/libEGL.c b/src/libEGL.c
new file mode 100644
index 0000000..da858bc
--- /dev/null
+++ b/src/libEGL.c
@@ -0,0 +1,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);
+}