|
|
@ -81,6 +81,8 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable { |
|
|
|
private GLFWWindowSizeCallback windowSizeCallback; |
|
|
|
private GLFWWindowSizeCallback windowSizeCallback; |
|
|
|
private GLFWWindowFocusCallback windowFocusCallback; |
|
|
|
private GLFWWindowFocusCallback windowFocusCallback; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Thread mainThread; |
|
|
|
|
|
|
|
|
|
|
|
public LwjglWindow(final JmeContext.Type type) { |
|
|
|
public LwjglWindow(final JmeContext.Type type) { |
|
|
|
if (!JmeContext.Type.Display.equals(type) && !JmeContext.Type.OffscreenSurface.equals(type) && !JmeContext.Type.Canvas.equals(type)) { |
|
|
|
if (!JmeContext.Type.Display.equals(type) && !JmeContext.Type.OffscreenSurface.equals(type) && !JmeContext.Type.Canvas.equals(type)) { |
|
|
|
throw new IllegalArgumentException("Unsupported type '" + type.name() + "' provided"); |
|
|
|
throw new IllegalArgumentException("Unsupported type '" + type.name() + "' provided"); |
|
|
@ -210,7 +212,6 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void invoke(final long window, final int focused) { |
|
|
|
public void invoke(final long window, final int focused) { |
|
|
|
final boolean focus = (focused == GL_TRUE); |
|
|
|
final boolean focus = (focused == GL_TRUE); |
|
|
|
|
|
|
|
|
|
|
|
if (wasActive != focus) { |
|
|
|
if (wasActive != focus) { |
|
|
|
if (!wasActive) { |
|
|
|
if (!wasActive) { |
|
|
|
listener.gainFocus(); |
|
|
|
listener.gainFocus(); |
|
|
@ -241,10 +242,6 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable { |
|
|
|
glfwSwapInterval(0); |
|
|
|
glfwSwapInterval(0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Make the window visible
|
|
|
|
|
|
|
|
if (Type.Display.equals(type)) { |
|
|
|
|
|
|
|
glfwShowWindow(window); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glfwShowWindow(window); |
|
|
|
glfwShowWindow(window); |
|
|
|
|
|
|
|
|
|
|
@ -286,17 +283,16 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void create(boolean waitFor) { |
|
|
|
public void create(boolean waitFor) { |
|
|
|
if (created.get()) { |
|
|
|
if (created.get()) { |
|
|
|
LOGGER.warning("create() called when display is already created!"); |
|
|
|
LOGGER.warning("create() called when display is already created!"); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
new Thread(this, THREAD_NAME).start(); |
|
|
|
// NOTE: this is required for Mac OS X!
|
|
|
|
|
|
|
|
mainThread = Thread.currentThread(); |
|
|
|
if (waitFor) { |
|
|
|
run(); |
|
|
|
waitFor(true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -307,6 +303,7 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable { |
|
|
|
if (!JmeSystem.isLowPermissions()) { |
|
|
|
if (!JmeSystem.isLowPermissions()) { |
|
|
|
// Enable uncaught exception handler only for current thread
|
|
|
|
// Enable uncaught exception handler only for current thread
|
|
|
|
Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { |
|
|
|
Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void uncaughtException(Thread thread, Throwable thrown) { |
|
|
|
public void uncaughtException(Thread thread, Throwable thrown) { |
|
|
|
listener.handleError("Uncaught exception thrown in " + thread.toString(), thrown); |
|
|
|
listener.handleError("Uncaught exception thrown in " + thread.toString(), thrown); |
|
|
|
if (needClose.get()) { |
|
|
|
if (needClose.get()) { |
|
|
@ -434,6 +431,7 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable { |
|
|
|
LOGGER.fine("Display destroyed."); |
|
|
|
LOGGER.fine("Display destroyed."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
if (listener == null) { |
|
|
|
if (listener == null) { |
|
|
|
throw new IllegalStateException("SystemListener is not set on context!" |
|
|
|
throw new IllegalStateException("SystemListener is not set on context!" |
|
|
@ -496,6 +494,11 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable { |
|
|
|
public void destroy(boolean waitFor) { |
|
|
|
public void destroy(boolean waitFor) { |
|
|
|
needClose.set(true); |
|
|
|
needClose.set(true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mainThread == Thread.currentThread()) { |
|
|
|
|
|
|
|
// Ignore waitFor.
|
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (waitFor) { |
|
|
|
if (waitFor) { |
|
|
|
waitFor(false); |
|
|
|
waitFor(false); |
|
|
|
} |
|
|
|
} |
|
|
|