4

我正在运行这个简单的代码来使用 lwjgl 在 Eclipse 中显示一个窗口:

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

@SuppressWarnings("unused")
public class DisplayExample {

public void start() {
    try {
        Display.setDisplayMode(new DisplayMode(1920, 1080));
        Display.create();




    } catch (LWJGLException e) {
        e.printStackTrace();
        System.exit(0);
    }

    // init OpenGL here

    while (!Display.isCloseRequested()) {

        // render OpenGL here

        Display.update(); //flushes OpenGL pipeline and swaps back and front buffers. perhaps waits for v-sync.
    }

    Display.destroy();
}

public static void main(String[] argv) {
    DisplayExample displayExample = new DisplayExample();
    displayExample.start();
}
}

然而屏幕出现这样并且闪烁: http://tinypic.com/r/33upp2u/6 这是在mac上运行,任何想法出了什么问题?

4

1 回答 1

7

在更新显示之前,您没有清除屏幕。GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);之前添加// render OpenGL here。您还需要为此导入org.lwjgl.opengl.GL11类。

于 2012-10-14T17:40:13.633 回答