Search code examples
javamacoslwjgl

LWJGL Display.isCloseRequested() throwing an error?


Well I am currently using a Mac, and I was just creating a simple LWJGL test program to make sure the library would work... but when I try to get the closed requested state for the Display, it throws an error...

I am currently using Mac OSX 10.7.5, I am using LWJGL 2.8.5, and I'm running the latest java (1.7.0_13). If this is an error made by me, please don't hesitate to point it out.

The error:

JavaVM WARNING: JAWT_GetAWT must be called after loading a JVM
Fatal error: Unable to create window.
org.lwjgl.LWJGLException: Could not get the JAWT interface
Exception in thread "main" java.lang.IllegalStateException: Cannot determine close requested state of uncreated window
    at org.lwjgl.opengl.Display.isCloseRequested(Display.java:546)
    at lwjgltest.LWJGLTest.start(LWJGLTest.java:26)
    at lwjgltest.LWJGLTest.main(LWJGLTest.java:13)
Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)

The code:

package lwjgltest;

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;

/**
 *
 * @author DealerNextDoor
 */
public class LWJGLTest {
    public static void main(String[] args) {
        new LWJGLTest().start(); // Line 13
    }

    public void start() {
        try {
            Display.setDisplayMode(new DisplayMode(640, 480));
            Display.setTitle("LWJGL Test");
            Display.create();
        } catch (LWJGLException e) {
            System.err.println("Fatal error: Unable to create window.");
            System.err.println(e);
        }

        while (!Display.isCloseRequested()) { // Line 26

            Display.update();
            Display.sync(60);
        }

        Display.destroy();
    }
}

Solution

  • If you'll look at your error you will find that a window was not created: Fatal error: Unable to create window.

    As a result, you cannot use the method isCloseRequested().

    I think that you will find some information about why it is not creating here