From 793d5888769a7351fc699a31f6caa73bcbcbe338 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Sun, 11 Mar 2018 18:24:08 +0200 Subject: android/EGL: Mark ANativeWindow w/ header Remove eglGetDisplay as it's called with NULL anyways (Reimplement if otherwise in some app) In eglCreateWindowSurface, check that our pointer really is ANativeWindow, otherwise try use it as is. --- src/libEGL.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src/libEGL.c') diff --git a/src/libEGL.c b/src/libEGL.c index 45e8ffb..f2d9585 100644 --- a/src/libEGL.c +++ b/src/libEGL.c @@ -1,28 +1,21 @@ #include +#include #include -#define GLFW_INCLUDE_NONE #include #define GLFW_EXPOSE_NATIVE_X11 #include struct ANativeWindow { + char header[4]; GLFWwindow *glfw; }; -EGLDisplay -eglGetDisplay(EGLNativeDisplayType native_display) -{ - static union { EGLDisplay (*fun)(EGLNativeDisplayType); void *ptr; } orig; - if (!orig.ptr) orig.ptr = dlsym(RTLD_NEXT, "eglGetDisplay"); - return orig.fun(glfwGetX11Display()); -} - EGLSurface eglCreateWindowSurface(EGLDisplay display, EGLConfig config, NativeWindowType native_window, EGLint const *attrib_list) { static union { EGLSurface (*fun)(EGLDisplay, EGLConfig, NativeWindowType, EGLint const*); void *ptr; } orig; if (!orig.ptr) orig.ptr = dlsym(RTLD_NEXT, "eglCreateWindowSurface"); struct ANativeWindow *window = (struct ANativeWindow*)native_window; - return orig.fun(display, config, glfwGetX11Window(window->glfw), attrib_list); + return orig.fun(display, config, (!memcmp(window->header, "andr", sizeof(window->header)) ? glfwGetX11Window(window->glfw) : native_window), attrib_list); } -- cgit v1.2.3