summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-03-11 18:24:08 +0200
committerJari Vetoniemi <mailroxas@gmail.com>2018-03-11 18:24:08 +0200
commit793d5888769a7351fc699a31f6caa73bcbcbe338 (patch)
tree68d4a1bb148f7503ae8e223831f93216ac96bb18 /src
parent327da9112b166bb31218fa828a44413db7fee284 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/libEGL.c13
-rw-r--r--src/libandroid.c4
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);