import org.lwjgl.opengl.*;import org.lwjgl.Sys;public class display {// in this case we only care about the dimensions of the screen, we're aiming// for an 800x600 display. int targetWidth = 800; int targetHeight = 600; DisplayMode chosenMode = null; try { DisplayMode[] modes = Display.getAvailableDisplayModes(); for (int i=0;i<modes.length;i++) { if ((modes[i].getWidth() == targetWidth) && (modes[i].getHeight() == targetHeight)) { chosenMode = modes[i]; break; } } } catch (LWJGLException e) { Sys.alert("Error", "Unable to determine display modes."); System.exit(0); }// at this point if we have no mode there was no appropriate, let the user know // and give up if (chosenMode == null) { Sys.alert("Error", "Unable to find appropriate display mode."); System.exit(0); } try { Display.setDisplayMode(chosenMode); Display.setTitle("An example title"); Display.create(); } catch (LWJGLException e) { Sys.alert("Unable to create display.", "o"); System.exit(0); }// go on to do any initialisation of OpenGL here, for example loading textures// or setting up basic global settings GL11.glClearColor(0,0,0,0); boolean gameRunning = true; float pos = 0; while (gameRunning) { // perform game logic updates here pos += 0.01f; // render using OpenGL GL11.glBegin(GL11.GL_QUADS); GL11.glVertex3f(0,0,pos); GL11.glVertex3f(1,0,pos); GL11.glVertex3f(1,1,pos); GL11.glVertex3f(0,1,pos); GL11.glEnd(); // now tell the screen to update Display.update(); // finally check if the user has requested that the display be // shutdown if (Display.isCloseRequested()) { gameRunning = false; Display.destroy(); System.exit(0); } }}