0

好吧,我目前正在使用 Mac,我只是在创建一个简单的 LWJGL 测试程序以确保该库能够正常工作……但是当我尝试获取显示器的关闭请求状态时,它会引发错误……

我目前使用的是 Mac OSX 10.7.5,我使用的是 LWJGL 2.8.5,并且我正在运行最新的 java (1.7.0_13)。如果这是我犯的错误,请不要犹豫指出。

错误:

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)

编码:

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();
    }
}
4

3 回答 3

0

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

于 2013-02-10T20:51:17.150 回答
0

将 java 降级到 1.6 应该会有所帮助。

于 2013-02-10T20:54:32.777 回答
0

我将我的移动Display.create();到类构造函数而不是方法内部,并且“无法确定未创建窗口的关闭请求状态”错误消失了。

public Core() { // Main class constructor

    try {
        LibraryLoader.loadNativeLibraries();
    } catch (Exception e) {
        e.printStackTrace();
        System.err.println("Error Loading Natives!");
    }

    Scanner in = new Scanner(System.in);
    startTime = System.currentTimeMillis();

    try {
        Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
        Display.create();
        input = new InputHandler();
        Display.setTitle(TITLE);
    } catch (LWJGLException e) {
        e.printStackTrace();
        System.exit(1);
        cleanUp();

    }
    initGL();
    mainLoop();

}
于 2017-03-10T22:02:58.100 回答