From 67487dcdba2bf84f3ca73c4d20194b0198974eb7 Mon Sep 17 00:00:00 2001 From: artdeell Date: Sun, 21 Feb 2021 10:56:38 +0300 Subject: [PATCH] change --- app_pojavlauncher/src/main/jni/egl_bridge.c | 12 +++--- .../src/main/java/org/lwjgl/glfw/GLFW.java | 1 + .../main/java/org/lwjgl/opengl/Display.java | 37 ++++++++++--------- .../java/org/lwjgl/opengl/SharedDrawable.java | 4 ++ 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/app_pojavlauncher/src/main/jni/egl_bridge.c b/app_pojavlauncher/src/main/jni/egl_bridge.c index 31d59aa58..bfd414f06 100644 --- a/app_pojavlauncher/src/main/jni/egl_bridge.c +++ b/app_pojavlauncher/src/main/jni/egl_bridge.c @@ -150,8 +150,8 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglInit(JNIEnv* env, j JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglMakeCurrent(JNIEnv* env, jclass clazz, jlong window) { EGLContext *currCtx = eglGetCurrentContext(); printf("EGLBridge: Comparing: thr=%d, this=%p, curr=%p\n", gettid(), window, currCtx); - if (window != 0x1 && (window == 0x0 || currCtx == EGL_NO_CONTEXT || currCtx == (EGLContext *) window)) { - if (window != 0x0 && potatoBridge.eglContextOld != NULL && potatoBridge.eglContextOld != (void *) window) { + if (currCtx == NULL || window == 0) { + /*if (window != 0x0 && potatoBridge.eglContextOld != NULL && potatoBridge.eglContextOld != (void *) window) { // Create new pbuffer per thread // TODO get window size for 2nd+ window! int surfaceWidth, surfaceHeight; @@ -164,14 +164,14 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglMakeCurrent(JNIEnv* }; potatoBridge.eglSurface = eglCreatePbufferSurface(potatoBridge.eglDisplay, config, surfaceAttr); printf("EGLBridge: created pbuffer surface %p for context %p\n", potatoBridge.eglSurface, window); - } - potatoBridge.eglContextOld = (void *) window; + }*/ + //potatoBridge.eglContextOld = (void *) window; // eglMakeCurrent(potatoBridge.eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); printf("EGLBridge: Making current on window %p on thread %d\n", window, gettid()); EGLBoolean success = eglMakeCurrent( potatoBridge.eglDisplay, - /* window==0 ? (EGLSurface *) 0 : */ potatoBridge.eglSurface, - /* window==0 ? (EGLSurface *) 0 : */ potatoBridge.eglSurface, + window==0 ? (EGLSurface *) 0 : potatoBridge.eglSurface, + window==0 ? (EGLSurface *) 0 : potatoBridge.eglSurface, /* window==0 ? EGL_NO_CONTEXT : */ (EGLContext *) window ); if (success == EGL_FALSE) { diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFW.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFW.java index 237e7f626..5c02d30ce 100644 --- a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFW.java +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFW.java @@ -963,6 +963,7 @@ public class GLFW e.printStackTrace(); } nativeEglMakeCurrent(window); + System.out.println(Long.toString(nativeEglGetCurrentContext(),16)); } public static void glfwSwapBuffers(long window) { diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Display.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Display.java index 357833a7d..dd00be706 100644 --- a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Display.java +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Display.java @@ -396,7 +396,25 @@ public class Display { displayY = (monitorHeight - mode.getHeight()) / 2; } - glfwMakeContextCurrent(Window.handle); + //glfwMakeContextCurrent(Window.handle); + final DrawableGL drawable = new DrawableGL() { + public void destroy() { + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) + return; + + releaseDrawable(); + super.destroy(); + destroyWindow(); + // x = y = -1; + // cached_icons = null; + reset(); + } + } + }; + drawable.context = new ContextGL(null, null, null); + drawable.context.makeCurrent(); + Display.drawable = drawable; context = org.lwjgl.opengl.GLContext.createFromCurrent(); glfwSwapInterval(0); @@ -714,24 +732,7 @@ public class Display { } }; - - final DrawableGL drawable = new DrawableGL() { - public void destroy() { - synchronized ( GlobalLock.lock ) { - if ( !isCreated() ) - return; - releaseDrawable(); - super.destroy(); - destroyWindow(); - // x = y = -1; - // cached_icons = null; - reset(); - } - } - }; - drawable.context = new ContextGL(null, null, null); - Display.drawable = drawable; displayCreated = true; diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/SharedDrawable.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/SharedDrawable.java index 6cefe0f6c..a19d2c5c8 100644 --- a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/SharedDrawable.java +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/SharedDrawable.java @@ -59,4 +59,8 @@ public final class SharedDrawable extends DrawableGL { // throw new UnsupportedOperationException(); } + @Override + public void makeCurrent() throws LWJGLException { + //stub + } }