显示问题 LWJGL

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上运行,有什么想法是出了什么问题吗?
1个回答

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接