summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--src/libEGL.c26
2 files changed, 30 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index b21f2e6..ae7e79c 100644
--- a/Makefile
+++ b/Makefile
@@ -43,7 +43,10 @@ runtime/libpthread.so: runtime src/libpthread.c
runtime/libandroid.so: private LDLIBS += `pkg-config --libs glfw3`
runtime/libandroid.so: runtime src/libandroid.c
runtime/liblog.so: runtime src/liblog.c
-native: runtime/libdl.so runtime/libc.so runtime/libpthread.so runtime/libandroid.so runtime/liblog.so
+runtime/libEGL.so: private CPPFLAGS += -D_GNU_SOURCE
+runtime/libEGL.so: private LDLIBS += -lEGL
+runtime/libEGL.so: runtime src/libEGL.c
+native: runtime/libdl.so runtime/libc.so runtime/libpthread.so runtime/libandroid.so runtime/liblog.so runtime/libEGL.so
jvm.a: private CPPFLAGS += -D_GNU_SOURCE
jvm.a: private CFLAGS += -Wno-unused-variable -Wno-pedantic
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);
+}