Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glfw causes program to hang #68

Closed
thislooksfun opened this issue Jun 20, 2015 · 5 comments

Comments

Projects
None yet
6 participants
@thislooksfun
Copy link

commented Jun 20, 2015

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

@FortressBuilder

This comment has been minimized.

Copy link

commented Jun 20, 2015

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);
        // ...
    }
}
@kenzierocks

This comment has been minimized.

Copy link
Contributor

commented Jun 20, 2015

I don't get this freeze on Windows -- possibly platform specific?

@Cethric

This comment has been minimized.

Copy link

commented Jun 20, 2015

The freeze also occurs on Mac (tested on OSX 10.10)

@sriharshachilakapati

This comment has been minimized.

Copy link
Contributor

commented Jun 20, 2015

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.

@Spasi

This comment has been minimized.

Copy link
Member

commented Jun 20, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.