@Override public void run() { long lastTime = System.nanoTime(); start(); long now = System.nanoTime(); long timer = System.currentTimeMillis(); double delta = 0; int frames = 0; int updates = 0; System.out.println("Initialized in " + ((now - lastTime) / 1000000000.0) + " seconds"); while (!Display.isCloseRequested()) { now = System.nanoTime(); delta += (now - lastTime) / NANOSECS; lastTime = now; while (delta >= 1) { update(updates); updates++; delta--; } render(); frames++; if (System.currentTimeMillis() - timer > 1000) { timer += 1000; Display.setTitle("SplitMan | FPS: " + frames + " | UPS: " + updates); frames = 0; updates = 0; } Display.update(); Display.sync(120); } stop(); }
public void start() { try { Display.setDisplayMode(new DisplayMode(800, 600)); Display.create(); } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } initGL(); // init OpenGL getDelta(); // call once before loop to initialise lastFrame lastFPS = getTime(); // call before loop to initialise fps timer while (!Display.isCloseRequested()) { int delta = getDelta(); update(delta); renderGL(); Display.update(); Display.sync(60); // cap fps to 60fps } Display.destroy(); }
public void draw() { // Clear The Screen And The Depth Buffer GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); if (camera != null) { camera.updatePosition(); } else { camera = (Camera) object_list.getItem(Camera.CAMERA_NAME); if (camera != null) { camera.updatePosition(); } else { System.out.println("WARNING: Tried to draw without camera set..."); return; } } // Draw the 3d stuff for (Entity ent : object_list.getEntitiesAndSubEntities()) { Boolean should_draw = (Boolean) ent.getProperty(Entity.SHOULD_DRAW); if (should_draw == null) should_draw = false; if (should_draw) ent.drawProgrammablePipe(); } // Draw the window manager stuff if (window_manager != null) window_manager.draw(); Display.update(); }
/** Runs the game (the "main loop") */ private static void run() { while (!finished) { // Always call Window.update(), all the time Display.update(); if (Display.isCloseRequested()) { // Check for O/S close requests finished = true; } else if (Display.isActive()) { // The window is in the foreground, so we should play the game logic(); render(); Display.sync(FRAMERATE); } else { // The window is not in the foreground, so we can allow other stuff to run and // infrequently update try { Thread.sleep(100); } catch (InterruptedException e) { } logic(); if (Display.isVisible() || Display.isDirty()) { // Only bother rendering if the window is visible or dirty render(); } } } }
/** * The menu sequence that allows the user to select options. * * <p> * * <ul> * <li>QuickStart (random character created for the player) * <li>Create new character * <li>Load a character * <li> * <li>Settings, including keybindings * <li>Quit * </ul> */ private void menuSelectionSequence() { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); Input.poll(); mouseEvents = Input.getMouseEvents(); for (GLUIComponent b : menuSelectionButtons) { b.processMouseEvents(mouseEvents); b.update(0); b.renderGL(); } try { menuTheme .getFont() .glDrawText( "\\c#FFFFFFUniQuest", (Main.SCREEN_WIDTH - menuTheme.getFont().getStringWidth("UniQuest")) / 2 + 2, 50); } catch (InvalidEscapeSequenceException e) { e.printStackTrace(); } Display.update(); if (Display.isCloseRequested()) { Game.GAME_STATE = Game.GAME_STATE_QUIT; menu = false; } }
public static void main(String[] args) throws InterruptedException { try { Display.setTitle("Simple Square"); Display.create(); } catch (LWJGLException e) { e.printStackTrace(); } // draw the square glBegin(GL_LINE_LOOP); glVertex3f(-0.5f, -0.5f, 0f); glVertex3f(-0.5f, 0.5f, 0f); glVertex3f(0.5f, 0.5f, 0f); glVertex3f(0.5f, -0.5f, 0f); glEnd(); // flush any commands that are still hanging about. glFlush(); // update window. Display.update(); while (!Display.isCloseRequested()) { Thread.sleep(100); } Display.destroy(); }
private void run() { int frames = 0; double nsPerFrame = 1000000000.0 / 60.0; double unProcessed = 0; long lastFrameTime = System.nanoTime(); long currentFrameTime = System.currentTimeMillis(); while (running) { long now = System.nanoTime(); unProcessed += (now - lastFrameTime) / nsPerFrame; lastFrameTime = now; if (Display.isCloseRequested()) running = false; while (unProcessed > 1) { unProcessed -= 1; tick(); display.render(); } frames++; if (System.currentTimeMillis() - currentFrameTime > 1000) { currentFrameTime += 1000; // Print.line(frames + " fps"); Display.setTitle(frames + " fps"); frames = 0; } Display.sync(60); Display.update(); } Display.destroy(); }
public void waitForInput() { for (; ; ) { if (getInputCloseSignal()) return; // Display.sync(FPS); Display.update(); // update the view/screen } }
public void display(long deltaTime) { Display.sync(60); elapsedTime += deltaTime; if (Display.wasResized()) resize(); float[] offsets = computePositionOffsets(0, 0, deltaTime); float xOffset = offsets[0]; float yOffset = offsets[1]; adjustVertexData(xOffset, yOffset); glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); glUseProgram(program); glBindBuffer(GL_ARRAY_BUFFER, positionBufferObject); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 4, GL_FLOAT, false, 0, 0); glDrawArrays(GL_TRIANGLES, 0, 3); glDisableVertexAttribArray(0); glUseProgram(0); Display.update(); // calls (among other things) swapBuffers() }
public void start() { try { Display.setDisplayMode(new DisplayMode(800, 600)); Display.create(); } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } initGL(); // init OpenGL try { font = new Font("assets/text.png", "assets/text.txt", 6, 13); font.buildFont(2); // build the textures for text s = new Sprite("assets/pokemon_sprites/front/643.png"); } catch (IOException e) { e.printStackTrace(); System.exit(0); } getDelta(); // call once before loop to initialise lastFrame lastFPS = getTime(); // call before loop to initialise fps timer while (!Display.isCloseRequested() && !finished) { int delta = getDelta(); update(delta); renderGL(); Display.update(); Display.sync(60); // cap fps to 60fps } Display.destroy(); }
/* (non-Javadoc) * @see chu.engine.Game#loop() */ @Override public void loop() { while (!Display.isCloseRequested()) { final long time = System.nanoTime(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glClearDepth(1.0f); getInput(); final ArrayList<Message> messages = new ArrayList<>(); if (client != null) { synchronized (client.messagesLock) { messages.addAll(client.messages); for (Message m : messages) client.messages.remove(m); } } SoundStore.get().poll(0); glPushMatrix(); // Global resolution scale // Renderer.scale(scaleX, scaleY); currentStage.beginStep(messages); currentStage.onStep(); currentStage.processAddStack(); currentStage.processRemoveStack(); currentStage.render(); // FEResources.getBitmapFont("stat_numbers").render( // (int)(1.0f/getDeltaSeconds())+"", 440f, 0f, 0f); currentStage.endStep(); glPopMatrix(); Display.update(); timeDelta = System.nanoTime() - time; } AL.destroy(); Display.destroy(); if (client != null && client.isOpen()) client.quit(); }
public void start() { // ウィンドウの生成 try { Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT)); // Display.setTitle("SimField"); Display.create(); } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } initGL(); // メインループ while (!Display.isCloseRequested()) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); /** * for(Life l : lifeSet.getArray()){ l.renderLife(); } for(Life lr: lifeRedSet.getArray()){ * lr.renderLife(); } for(Life lb: lifeBlueSet.getArray()){ lb.renderLife(); } */ for (Life l : life) { l.renderLife(); } for (Life lr : lifeRed) { lr.renderLife(); } for (Life lb : lifeBlue) { lb.renderLife(); } status.updateFPS(); Display.update(); // オンスクリーンに反映 Display.sync(60); // FPSを60に固定 } }
private void mainLoop() { long startTime = 0L; long endTime = 0L; long deltaTime = 0L; while (!Display.isCloseRequested()) { startTime = System.currentTimeMillis(); // Run the physics simulation if (useOpenCL) { clPhysics.doPhysics(particleCount, deltaTime); // Render Renderer.render(clPhysics.getCurrentPosBuffer(), particleCount); } else { normalPhysics.doPhysics(particles, boxWidth, boxHeight, deltaTime); // Render Renderer.render(particles); } // Update the display Display.update(); endTime = System.currentTimeMillis(); deltaTime = endTime - startTime; System.out.println(deltaTime); } }
void apply(float[][][] m) { if (WorldGenerator.scrn != null) WorldGenerator.scrn.setLabel("Applying"); for (int x = 0; x < length; x++) { for (int y = 0; y < length; y++) { for (int z = 0; z < length; z++) { if (z < 127) { float i = m[x][y][z]; if (i > 0.45f) world.setBlock(x, y, z / 2, Block.grass); } else { float i = m[x][y][127]; if (i > 0.45f) for (int z1 = 64; z1 < (int) 64 + (i - 0.45f) * 16; z1++) world.setBlock(x, y, z1, Block.grass); } } } if (x % 4 == 0 && WorldGenerator.scrn != null) { WorldGenerator.scrn.setProgress(x / (float) length); WorldGenerator.scrn.draw(); Display.update(); } } }
/** * Start the application. The window is opened and the main loop is entered. This call does not * return until the window is closed or an exception was caught. */ public void start() { try { Display.setDisplayMode(new DisplayMode(width, height)); Display.setTitle(title); if (multisampling) Display.create(new PixelFormat().withSamples(8)); else Display.create(); // Sync buffer swap with vertical sync. Results in 60 fps on my Mac // Book. Display.setSwapInterval(1); Display.setVSyncEnabled(true); input = new Input(); application.init(); while (!Display.isCloseRequested()) { input.update(); input.setWindowSize(width, height); application.simulate(time.elapsed(), input); application.display(width, height, input); Display.update(); } } catch (LWJGLException e) { e.printStackTrace(); } finally { Display.destroy(); } }
public static void render() { GL11.glClearColor(0f, 255f / 191f, 1f, 0f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glColor3f(0.5f, 0.5f, 1.0f); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glLoadIdentity(); lookThrough(); /*doPicking(); namemap = new HashMap<Integer, Location>(); Render.renderArray(world.getSpawn()); GL11.glLoadIdentity(); game.render(); stopPicking();*/ // Picking junk /*GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glColor3f(0.5f,0.5f,1.0f); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glLoadIdentity(); lookThrough();*/ Render.renderArray(world.getSpawn()); Render.renderEntities(world.entities); /*GL11.glLoadIdentity(); game.render();*/ Display.update(); }
/** Enters the Main-Loop */ private void beginLoop() { this.isRunning = true; this.timing.init(); while (this.isRunning) { int delta = this.timing.getDelta(); this.handleDisplayResize(); if (Display.isCloseRequested()) this.isRunning = false; // Mouse updates this.profiler.start("Mouse updates"); this.mouseX = Mouse.getX(); this.mouseY = this.height - Mouse.getY(); if (!this.isGamePaused) { this.input.mousePos(this.mouseX, this.mouseY); if (Mouse.isButtonDown(0) && !this.lastButtonState) this.input.mouseClick(this.mouseX, this.mouseY); this.lastButtonState = Mouse.isButtonDown(0); } // Scrolling if (!this.isGamePaused) { int scroll = Mouse.getDWheel(); if (scroll > 0) this.camera.zoom(-1); else if (scroll < 0) this.camera.zoom(1); } // Keyboard updates this.profiler.endStart("Keyboard updates"); this.keyboardListener.update(); // Audio this.profiler.endStart("Audio updates"); this.soundEngine.update(delta); // Rendering this.profiler.endStart("Render game"); this.camera.update(delta); this.renderer.render(this.camera, this.logic.getGameState(), delta); this.profiler.endStart("Render GUI"); this.guiRenderer.render(this.width, this.height, this.mouseX, this.mouseY); this.profiler.end(); Display.update(); Display.sync(60); int error = glGetError(); if (error != GL_NO_ERROR) System.out.println("GLError " + error + ": " + GLU.gluErrorString(error)); this.timing.updateFPS(); } this.soundEngine.dispose(); Settings.saveSettings(this.settings); if (Display.isCreated()) Display.destroy(); }
private void draw() { // Clear the screen and depth buffer GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); // set up GameContext.getCamera() GL11.glPushMatrix(); GL11.glScalef(scale, scale, scale); GL11.glTranslatef( -GameContext.getCamera().getPosition().getx(), -GameContext.getCamera().getPosition().gety(), 0); GL11.glTranslatef(4f, 3f, 0); map.draw(); if (editorMode) { Quad q = new Quad(editorTag.getPosition(), map.getLookupTile(currentEditorTile).getTexture()); GameContext.getPipe().addDrawable(q); } for (Entity ae : entities) { ae.draw(); } GameContext.getPipe().renderContent(); GL11.glPopMatrix(); // overlay console text GL11.glPushMatrix(); GL11.glScalef(2f, 2f, 2f); if (console.isEnabled()) { gtest.drawing.util.drawString(new Coord(0, 0), "> " + console.getText()); } if (GameContext.isDebugMode()) { gtest.drawing.util.drawString( new Coord(0, 285), "tiles drawn " + GameContext.getFromLog("tilesLastDrawn")); gtest.drawing.util.drawString( new Coord(0, 275), "textures bound " + GameContext.getFromLog("textureBinds")); gtest.drawing.util.drawString(new Coord(0, 265), "FPS " + GameContext.getFromLog("fps")); } GL11.glPopMatrix(); Display.update(); // clean up GameContext.getPipe().clear(); GameContext.addToLog("tilesLastDrawn", "0"); GameContext.addToLog("textureBinds", "0"); }
public void run() { while (!Display.isCloseRequested()) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); gui.update(); Display.update(); TestUtils.reduceInputLag(); } }
private void loop() { while (!Display.isCloseRequested()) { run(); updateFPS(); Display.update(); Display.sync(60); } }
public static void renderScene() { game.render(); GL11.glColor3f(0.5f, 0.5f, 1.0f); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); Render.renderArray(world.getSpawn()); GL11.glLoadIdentity(); Display.update(); }
public static void toggleFullscreen() { Globals.fullscreen = !Globals.fullscreen; try { Display.setFullscreen(Globals.fullscreen); Display.update(); } catch (LWJGLException e) { e.printStackTrace(); } }
public void update() { GameTimer.update(); FramesCounter.updateFPS(gameState); inputManager.checkInput(); render.renderFrame(); Display.update(); Display.sync(60); movementManager.update(); }
/** * Connect to the server and execute the initial data exchange. Returns when the connection is * successfully established * * @return false if the connection failed and the game should quit (or go back to the menu) */ public boolean loop() { networkedGame = new NetworkedGame(loop, httpUrl, nickname); loadingCamera = new Camera(resourceDB); loadingStarfield = new StarField(SwissArmyKnife.random.nextInt(), resourceDB); loadingCamera.setScreenPosition(0, 0); loadingCamera.setPosition(0, loadingCameraY); connection = new SingleGameConnection(wsUri, loop); connection.addListener(networkedGame); connection.connect(); loop.addTickEvent(this); try { while (!loop.isInterruped() && networkedGame.isConnecting()) { Display.update(); if (Display.isCloseRequested()) { log.log(Level.WARNING, "Close requested in connect loop"); return false; } loadingCamera.setDimension(Display.getWidth(), Display.getHeight()); Graph.graphicsLoop(); Client.initGL(); loop.loop(); loadingStarfield.render(loadingCamera); String line = "Connecting..."; int line_width = Graph.g.getFont().getWidth(line); Graph.g.setColor(Color.white); Graph.g.drawString( line, loadingCamera.dimensionHalf.x - line_width / 2, loadingCamera.dimension.y * 0.75f); loadingCamera.setPosition(0, loadingCameraY); Display.sync(60); } if (loop.isInterruped()) { log.log(Level.WARNING, "Connect loop interrupted"); return false; } return !networkedGame.isConnecting() && !networkedGame.isDisconnected(); } finally { loop.removeTickEvent(this); } }
private void keyConfigSequence() { while (loop) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); try { menuTheme .getFont() .glDrawText( "\\c#FFFFFFKey Bindings", (Main.SCREEN_WIDTH - menuTheme.getFont().getStringWidth("Key Bindings")) / 2 + 2, 50); } catch (InvalidEscapeSequenceException e) { e.printStackTrace(); } Input.poll(); mouseEvents = Input.getMouseEvents(); keyEvents = Input.getKeyEvents(); try { drawKeyConfigText(margin, 75, 30); } catch (InvalidEscapeSequenceException e) { } for (GLUIComponent t : keyConfigTextField) { t.processKeyEvents(keyEvents); t.processMouseEvents(mouseEvents); t.update(0); t.renderGL(); } Display.update(); if (Display.isCloseRequested()) { Game.GAME_STATE = Game.GAME_STATE_QUIT; menu = false; loop = false; } else if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { loop = false; } } for (GLUIComponent t : keyConfigTextField) { if (t instanceof GLTextField) { ((GLTextField) t).setText(((GLTextField) t).getText().toUpperCase()); KeyBindings.valueOf(t.getContext().toString()) .setUserKey(Keyboard.getKeyIndex(((GLTextField) t).getText())); } } }
public static void setWindowResolution(int width, int height) { Globals.windowWidth = width; Globals.windowHeight = height; Globals.aspectRatio = (float) Globals.windowWidth / (float) Globals.windowHeight; Globals.windowMatrix.set( 1 / Globals.aspectRatio, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); // for(IWindowChangeListener lis : Globals.windowChangeListener) // { // lis.onWindowResolutionChange(Globals.windowWidth, Globals.windowHeight); // } try { DisplayMode[] modes = Display.getAvailableDisplayModes(); DisplayMode finalMode = new DisplayMode(Globals.getWindowWidth(), Globals.getWindowHeight()); for (int i = 0; i < modes.length; i++) { DisplayMode current = modes[i]; if (current.getWidth() == Globals.getWindowWidth() && current.getHeight() == Globals.getWindowHeight() && current.getBitsPerPixel() == 32 && current.getFrequency() == 60) finalMode = current; } Display.setDisplayMode(finalMode); if (!Display.isCreated()) { PixelFormat pixelFormat = new PixelFormat(); ContextAttribs contextAtrributes = new ContextAttribs(3, 2).withForwardCompatible(true).withProfileCore(true); Display.create(pixelFormat, contextAtrributes); } GL11.glViewport(0, 0, Globals.getWindowWidth(), Globals.getWindowHeight()); } catch (LWJGLException e) { e.printStackTrace(); System.exit(-1); } Display.update(); }
private void loop() { long lastFrameTime = 0; while (!Display.isCloseRequested()) { long now = System.nanoTime(); long renderFps = 30; long nanoPerFrame = 1000000000 / renderFps; // update the animation if (now - lastFrameTime >= nanoPerFrame) { lastFrameTime = now; angle += 2.0f; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); glRotatef(view_roty, 0.0f, 1.0f, 0.0f); glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); glPushMatrix(); glTranslatef(-3.0f, -2.0f, 0.0f); glRotatef(angle, 0.0f, 0.0f, 1.0f); glCallList(gear1); glPopMatrix(); glPushMatrix(); glTranslatef(3.1f, -2.0f, 0.0f); glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f); glCallList(gear2); glPopMatrix(); glPushMatrix(); glTranslatef(-3.1f, 4.2f, 0.0f); glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f); glCallList(gear3); glPopMatrix(); glPopMatrix(); Display.update(); } handleInput(); if (broadcastController != null) { submitFrame(); broadcastController.update(); } if (chatController != null) { chatController.update(); } } }
@Override public void handleOutput(List<Entity> collection) { if (getInputCloseSignal()) // read input System.exit(0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); for (Entity e : collection) render(e); Display.sync(FPS); // sync to fps Display.update(); // update the view/screen }
public void start() { try { Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT)); Display.create(); Display.setFullscreen(true); } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glClearAccum(0f, 0f, 0f, 1f); GL11.glClear(GL11.GL_ACCUM_BUFFER_BIT); while (!Display.isCloseRequested() && !finished) { if (System.currentTimeMillis() - time > 1000) { System.out.println(framecount + " FPS"); time = System.currentTimeMillis(); framecount = 0; } GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); GL11.glColor3f(1, 1, 1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glOrtho(0, WIDTH, HEIGHT, 0, -10, 10); Manager.DrawBackground(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glOrtho(0, WIDTH, HEIGHT, 0, -10, 10); GL11.glTranslatef(-Camera.x, -Camera.y, 0); Display.sync(60); Manager.Draw(); Manager.Update(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glOrtho(0, WIDTH, HEIGHT, 0, -10, 10); Manager.DrawForeground(); Display.update(); framecount++; } }
public static void loop() { while (CSGame.state == States.ThreeDeeTest) { // Clear the screen of its filthy contents glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Push the screen inwards at the amount of speed glTranslatef(0, 0, speed); // Begin drawing points glBegin(GL_POINTS); // Iterate of every point for (Point p : points) { // Draw the point at its coordinates glColor3f(0.0f, 1f, 0f); glVertex3f(p.x, p.y, p.z); } // Stop drawing points glEnd(); // If we're pressing the "up" key increase our speed if (Keyboard.isKeyDown(Keyboard.KEY_UP)) { speed += 0.01f; } // If we're pressing the "down" key decrease our speed if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) { speed -= 0.01f; } // Iterate over keyboard input events while (Keyboard.next()) { // If we're pressing the "space-bar" key reset our speed to zero if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) { speed = 0f; } // If we're pressing the "c" key reset our speed to zero and reset our position if (Keyboard.isKeyDown(Keyboard.KEY_C)) { speed = 0; glLoadIdentity(); } } if (Display.isCloseRequested()) { CSGame.state = States.Closing; break; } Debug.debugLoop(); // Update the display Display.update(); // Wait until the frame-rate is 60fps Display.sync(60); } }