use*_*791 4 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();
}
}
Run Code Online (Sandbox Code Playgroud)
然而屏幕看起来像这样闪烁:http: //tinypic.com/r/33upp2u/6 这是在Mac上运行,任何想法出了什么问题?
在更新显示之前,您没有清除屏幕.GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);之前添加// render OpenGL here.您还需要为此导入org.lwjgl.opengl.GL11类.