Closed thislooksfun closed 9 years ago
Just in case there's an error with GLFW, you should set up an error callback.
public class SnakeGame {
GLFWErrorCallback errorCallback;
// ...
private void init() {
errorCallback = Callbacks.errorCallbackPrint();
glfwSetErrorCallback(errorCallback);
// ...
}
}
I don't get this freeze on Windows -- possibly platform specific?
The freeze also occurs on Mac (tested on OSX 10.10)
This is because using those objects will cause the AWT to run it's event loop, and on OSX, the main thread is already used by GLFW. The solution is to set the headless property of the AWT to true.
System.setProperty("java.awt.headless", "true");
Set that property before creating the window, then create the window. Also note that you have to create the fonts or the resources only after the window is created.
LWJGL 3 is not compatible with AWT on Mac OS X. This has been discussed extensively in the LWJGL forum. Even though certain workarounds can work under very specific conditions, it is highly recommended to not use AWT/Swing with LWJGL 3.
For image loading and font rendering LWJGL 3 recently added STB bindings, you can use that instead of AWT. See these samples.
If you try to create a new Font object or call ImageIO.read() (only two I've discovered so far) after calling GLFW.glfwCreateWindow, the program will hang—as far as I can tell—indefinitely.
My source code is here if it helps. Main class is here