显示问题LWJGL

时间:2012-10-14 15:31:09

标签: java eclipse opengl lwjgl

我正在运行这个简单的代码,使用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上运行,任何想法出了什么问题?

1 个答案:

答案 0 :(得分:6)

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

相关问题