示例#1
0
 public static void updateDisplay() {
   if (Keyboard.isKeyDown(Keyboard.KEY_RETURN)) {
     toggle = true;
   } else {
     toggle = false;
   }
   if (toggle) {
     Display.sync(20);
   } else {
     Display.sync(FPS_CAP);
   }
   Display.update();
   long currentFrameTime = getCurrentTime();
   delta = (currentFrameTime - lastFrameTime) / 1000f;
   lastFrameTime = currentFrameTime;
 }
示例#2
0
  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();
  }
示例#3
0
  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に固定
    }
  }
  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();
  }
示例#5
0
  /** 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();
        }
      }
    }
  }
示例#6
0
 @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 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()
  }
  protected void runLoop() {
    if (!created.get()) {
      throw new IllegalStateException();
    }

    if (pbuffer.isBufferLost()) {
      pbuffer.destroy();

      try {
        pbuffer = new Pbuffer(width, height, pixelFormat, null);
        pbuffer.makeCurrent();

        // Context MUST be reset here to avoid invalid objects!
        renderer.invalidateState();
      } catch (LWJGLException ex) {
        listener.handleError("Failed to restore pbuffer content", ex);
      }
    }

    listener.update();
    checkGLError();

    renderer.postFrame();

    // Need to flush GL commands
    // to see any result on the pbuffer's front buffer.
    GL11.glFlush();

    int frameRate = settings.getFrameRate();
    if (frameRate >= 1) {
      Display.sync(frameRate);
    }
  }
示例#9
0
  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();
  }
示例#10
0
文件: LLC.java 项目: JackdDvice/LLC
  /** 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 loop() {
   while (!Display.isCloseRequested()) {
     run();
     updateFPS();
     Display.update();
     Display.sync(60);
   }
 }
示例#12
0
  /**
   * 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);
    }
  }
示例#13
0
 public void update() {
   GameTimer.update();
   FramesCounter.updateFPS(gameState);
   inputManager.checkInput();
   render.renderFrame();
   Display.update();
   Display.sync(60);
   movementManager.update();
 }
示例#14
0
  @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
  }
示例#15
0
文件: Game.java 项目: Woutwo/Project1
  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++;
    }
  }
示例#16
0
  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);
    }
  }
示例#17
0
 private void globaldraw() {
   GL11.glMatrixMode(GL11.GL_PROJECTION);
   GL11.glLoadIdentity();
   GL11.glOrtho(
       0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight(), -1, 1);
   GL11.glMatrixMode(GL11.GL_MODELVIEW);
   GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
   for (int i = 0; i < blocks.size(); i++) blocks.get(i).onDraw(xorig);
   player.onDraw();
   Display.sync(120);
   setPoints();
 }
示例#18
0
 /** Runs the game (the "main loop") */
 private static void run() {
   while (!finished) {
     Display.update();
     if (Display.isCloseRequested()) {
       finished = true;
     } else {
       logic();
       render();
       Display.sync(FRAMERATE);
     }
   }
 }
示例#19
0
 private void endThisLoop() {
   // FPS meter
   if (time <= System.currentTimeMillis() - 1000) {
     Display.setTitle("Simulating gravity @ " + frameNumber + " FPS"); // Normal
     FPS = frameNumber;
     frameNumber = 0;
     time = System.currentTimeMillis();
   } else {
     frameNumber++;
   }
   Display.update();
   Display.sync(60);
 }
  @Override
  public void render() {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    glPushMatrix();

    camera.applyMatrix();
    simpleRender();

    glPopMatrix();

    Display.update();
    Display.sync(60);
  }
 public static void main(String[] args) {
   setUpDisplay();
   setUpDisplayLists();
   setUpCamera();
   setUpLighting();
   while (!Display.isCloseRequested()) {
     render();
     checkInput();
     Display.update();
     Display.sync(60);
   }
   cleanUp();
   System.exit(0);
 }
示例#22
0
  public void update() {
    Display.update();
    Display.sync(fps);
    detectKonami();

    if (Constants.allowFullScr) {
      if ((fullScr && !Display.isFullscreen()) || (!fullScr && Display.isFullscreen())) {
        System.out.println("Performing Display.destroy()/create() cycle");
        sM = Display.getDisplayMode();
        Display.destroy();
        try {
          //					DisplayMode[] d = Display.getAvailableDisplayModes();
          //					int value = 0;
          //					int index = 0;
          //					for(int i = 0; i < d.length; i++){
          //						if(d[i].getWidth() > value){
          //							value = d[i].getWidth();
          //							index = i;
          //						}
          //					}
          Display.setDisplayMode(sM);
          Display.setTitle("Music Dots");
          Display.setFullscreen(fullScr);
          Display.create();
          Display.setVSyncEnabled(true);
          Constants.VIEW_HEIGHT = sM.getHeight();
          Constants.VIEW_WIDTH = sM.getWidth();
          setupOpenGl();
          Fonts.initialize();
        } catch (LWJGLException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    }

    Theme.setClearColor();

    // TODO: we should be calling a "recreateView" function and call this in there. Not sure why
    // we're recreating the view in an update function.
    if (!bPlayerModelInitialized) {
      StaticDrawer.initializeTextures();
      bPlayerModelInitialized = true;
    }

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  }
示例#23
0
  /**
   * Update and render the game
   *
   * @param delta The change in time since last update and render
   * @throws SlickException Indicates an internal fault to the game.
   */
  protected void updateAndRender(int delta) throws SlickException {
    storedDelta += delta;
    input.poll(width, height);

    SoundStore.get().poll(delta);
    if (storedDelta >= minimumLogicInterval) {
      try {
        if (maximumLogicInterval != 0) {
          long cycles = storedDelta / maximumLogicInterval;
          for (int i = 0; i < cycles; i++) {
            game.update(this, (int) maximumLogicInterval);
          }
          game.update(this, (int) (delta % maximumLogicInterval));
        } else {
          game.update(this, (int) storedDelta);
        }

        storedDelta = 0;
      } catch (Throwable e) {
        Log.error(e);
        throw new SlickException("Game.update() failure - check the game code.");
      }
    }

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glLoadIdentity();

    graphics.resetFont();
    graphics.resetLineWidth();
    graphics.setAntiAlias(false);
    try {
      game.render(this, graphics);
    } catch (Throwable e) {
      Log.error(e);
      throw new SlickException("Game.render() failure - check the game code.");
    }
    graphics.resetTransform();

    if (showFPS) {
      defaultFont.drawString(10, 10, "FPS: " + recordedFPS);
    }

    if (targetFPS != -1) {
      Display.sync(targetFPS);
    }
  }
示例#24
0
  public void start() {
    // init OpenGL here
    init(true, false);

    createDrawables();

    while (!Display.isCloseRequested()) {

      // render OpenGL here
      render();

      Display.update();
      Display.sync(60);
    }

    Display.destroy();
  }
 public PongGame() {
   setUpDisplay();
   setUpOpengGL();
   setUpEntities();
   setUpTimer();
   while (isRunning) {
     render();
     logic(getDelta());
     input();
     Display.update();
     Display.sync(60);
     if (Display.isCloseRequested()) {
       isRunning = false;
     }
   }
   Display.destroy();
 }
示例#26
0
  /** Initialisation de la fenêtre OpenGl, de la camera et des textures. */
  public final void initGL() {
    // Création de la fenetre
    try {
      if (Setting.getFullScreen()) {
        Display.setDisplayModeAndFullscreen(
            new DisplayMode(Setting.get3DWidth(), Setting.get3DHeight()));
      } else {
        Display.setDisplayMode(new DisplayMode(Setting.get3DWidth(), Setting.get3DHeight()));
      }

      Display.setTitle("Visualisation 3D");
      Display.sync(Setting.getFps());
      Display.create();

    } catch (LWJGLException e) {
      e.printStackTrace();
      System.exit(0);
    }

    float fAspect = (float) Setting.getWWidth() / (float) Setting.getWHeight();
    GL11.glViewport(0, 0, Setting.getWWidth(), Setting.getWHeight());
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GLU.gluPerspective(45.0f, fAspect, 1.0f, 1000.0f);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glEnable(GL11.GL_CULL_FACE);

    // Initialisation de la Camera
    camera = new Camera("3D");
    camera.init();
    camera.yaw(140.0f);
    camera.pitch(20.0f);

    // Récupération des textures
    textures = new Textures();
    textures.init();
    textures.loadTexture();

    wind = new Wind();

    matrice.loadImg();
  }
示例#27
0
  /**
   * The opening sequence for the very first screen of the menu.
   *
   * <p>This will be the first thing that the user sees, so make it fancy!
   */
  @SuppressWarnings("unused")
  private void openingSequence() {

    boolean done = false;
    long start = System.currentTimeMillis();

    String title = "UniQuest";
    String text = "Welcome";

    int x0 = -menuTheme.getFont().getStringWidth(title);
    int x1 = Main.SCREEN_WIDTH;

    int a0 = (Main.SCREEN_WIDTH - menuTheme.getFont().getStringWidth(title)) / 2;
    int a1 = (Main.SCREEN_WIDTH - menuTheme.getFont().getStringWidth(text)) / 2;

    while (!done) {

      GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

      Display.sync(60);

      if (x0 < a0) x0 += a0 / 60;
      if (x1 > a1) x1 -= a1 / 60;

      GL11.glColor3f(1.0f, 1.0f, 1.0f);

      try {
        menuTheme.getFont().glDrawText("\\c#FFFFFF" + title, x0, 50);
        menuTheme.getFont().glDrawText("\\c#FFFFFF" + text, x1, 75);
      } catch (InvalidEscapeSequenceException e) {
        e.printStackTrace();
      }

      Display.update();

      if (System.currentTimeMillis() - start > 2500 || Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
        done = true;
      } else if (Display.isCloseRequested()) {
        done = true;
        Game.GAME_STATE = Game.GAME_STATE_QUIT;
      }
    }
  }
示例#28
0
  public void render() {

    glClear(GL_COLOR_BUFFER_BIT);
    glLoadIdentity();

    Collections.sort(Handler.renderables);

    for (Renderable renderable : Handler.renderables) {
      renderable.render();
    }

    /*
     * EntityHandler.render();
    SpellHandler.render();
     */

    Display.update();
    Display.sync(60);
  }
示例#29
0
  public static void main(String[] args) {
    try {
      Display.setDisplayMode(new DisplayMode(640, 480));
      Display.setTitle("Timer Demo");
      Display.create();
    } catch (LWJGLException e) {
      e.printStackTrace();
      Display.destroy();
      System.exit(1);
    }

    int x = 100;
    int y = 100;
    int dx = 1;
    int dy = 1;

    // Initialization code OpenGL
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, 640, 480, 0, 1, -1);
    glMatrixMode(GL_MODELVIEW);

    lastFrame = getTime();

    while (!Display.isCloseRequested()) {
      // Render

      glClear(GL_COLOR_BUFFER_BIT);

      double delta = getDelta();
      x += delta * dx * 0.1;
      y += delta * dy * 0.1;

      glRecti(x, y, x + 30, y + 30);

      Display.update();
      Display.sync(60);
    }

    Display.destroy();
    System.exit(0);
  }
  public TheQuadExampleInterleaved() {
    // Initialize OpenGL (Display)
    this.setupOpenGL();

    this.setupQuad();
    this.setupShaders();

    while (!Display.isCloseRequested()) {
      // Do a single loop (logic/render)
      this.loopCycle();

      // Force a maximum FPS of about 60
      Display.sync(60);
      // Let the CPU synchronize with the GPU if GPU is tagging behind
      Display.update();
    }

    // Destroy OpenGL (Display)
    this.destroyOpenGL();
  }