AWT can't be used with LWJGL3 on MacOS X
krukhlis opened this issue · comments
As continuation of the
#4
After I've passed the corresponding param to jvm via modified run
task, Mundus editor has successfully started. But when I've tried WSAD keys to move my camera around -- the Mundus window has disappeared( but the process wasn't killed). I had 3 retries with the same result. So I've tried to figure out and it seems that the statement from GLFW in exception covers the reason:
Please run the JVM with -XstartOnFirstThread and
make sure a window toolkit other than GLFW (e.g. AWT or JavaFX) is not initialized.
at org.lwjgl.glfw.EventLoop
I have added jvmArgs "-Djava.awt.headless=true"
to the run task extended in #4
and had to remove the GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
from com.mbrlabs.mundus.Main
because it throws exception in headless mode.
After such set of changes everything works like a charm.
I've checked another projects -- it seems like all of them have the same issues on MacOS X and similar way to fix.
E.g. check https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/build.gradle
its run task has the same:
task run(dependsOn: 'build', type:JavaExec) {
main = mainClass
classpath = sourceSets.main.runtimeClasspath
if (System.properties['os.name'].toLowerCase().contains('mac')) {
jvmArgs "-XstartOnFirstThread"
jvmArgs "-Djava.awt.headless=true"
}
You're right. Awt & glfw shouldn't be used together.
There may be be a GLFW replacement for the GraphicsEnvironment part of AWT.
I am going to take a look at this as soon as i have time.
Worth mentioning that headless stuff form AWT (eg. ImageIO
) can still be safely used.
GraphicsEnvironment
can be probably replaced by new libgdx's APIs.
Nice, thanks kotcrab
Hi, I've submitted PR to fix both issues and get rid of AWT( Using pure Libgdx means).