I am running this simple code to display a window in eclipse using lwjgl:
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();
}
}
However the screen appears like this and is flickering:
http://tinypic.com/r/33upp2u/6
This is running on a mac, any ideas what is going wrong?
You aren’t clearing the screen before you update the display. Add
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);before// render OpenGL here. You also need to import theorg.lwjgl.opengl.GL11class for this.