diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libEGL.c | 13 | ||||
-rw-r--r-- | src/libandroid.c | 4 |
2 files changed, 7 insertions, 10 deletions
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 <dlfcn.h> +#include <string.h> #include <EGL/egl.h> -#define GLFW_INCLUDE_NONE #include <GLFW/glfw3.h> #define GLFW_EXPOSE_NATIVE_X11 #include <GLFW/glfw3native.h> 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); } diff --git a/src/libandroid.c b/src/libandroid.c index 1d677ae..eff3b3a 100644 --- a/src/libandroid.c +++ b/src/libandroid.c @@ -2,6 +2,7 @@ #include <stdint.h> #include <stdlib.h> #include <stdio.h> +#include <string.h> #include <assert.h> #define GLFW_INCLUDE_NONE @@ -428,6 +429,7 @@ AInputQueue_finishEvent(struct AInputQueue *queue, struct AInputEvent *event, in // ANative struct ANativeWindow { + char header[4]; GLFWwindow *glfw; }; @@ -477,6 +479,8 @@ ANativeWindow_fromSurface(JNIEnv* env, jobject surface) if (!(window = calloc(1, sizeof(*window)))) return NULL; + memcpy(window->header, "andr", sizeof(window->header)); + glfwInit(); fprintf(stderr, "glfw: %s\n", glfwGetVersionString()); glfwSetErrorCallback(glfw_error_cb); |