示例#1
0
  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();
  }
  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();
  }
示例#3
0
  public void start() {
    System.out.println("SplitMan starting...");
    try {
      Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
      Display.setResizable(false);
      Display.setVSyncEnabled(true);
      Display.setTitle("SplitMan");
      Display.create();
    } catch (Exception e) {
      e.printStackTrace();
      Display.destroy();
      System.exit(1);
    }
    WIDTH = Display.getWidth();
    HEIGHT = Display.getHeight();
    System.out.println("Display: " + WIDTH + " x " + HEIGHT);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, WIDTH, HEIGHT, 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    Resources.load();

    setScreen(new GuiGame());
    System.out.println("SplitMan started");
  }
示例#4
0
 public void shutdownMinecraftApplet() {
   try {
     statFileWriter.func_27175_b();
     statFileWriter.syncStats();
     if (mcApplet != null) {
       mcApplet.clearApplet();
     }
     try {
       if (downloadResourcesThread != null) {
         downloadResourcesThread.closeMinecraft();
       }
     } catch (Exception exception) {
     }
     System.out.println("Stopping!");
     try {
       changeWorld1(null);
     } catch (Throwable throwable) {
     }
     try {
       GLAllocation.deleteTexturesAndDisplayLists();
     } catch (Throwable throwable1) {
     }
     sndManager.closeMinecraft();
     Mouse.destroy();
     Keyboard.destroy();
   } finally {
     Display.destroy();
     if (!hasCrashed) {
       System.exit(0);
     }
   }
   System.gc();
 }
 private static void cleanUp() {
   glDeleteProgram(perPixelShaderProgram);
   glDeleteProgram(perVertexShaderProgram);
   glDeleteBuffers(vboVertexHandle);
   glDeleteBuffers(vboNormalHandle);
   Display.destroy();
 }
示例#6
0
 @Override
 public void close() {
   AL.destroy();
   Display.destroy();
   org.lwjgl.input.Mouse.destroy();
   org.lwjgl.input.Keyboard.destroy();
 }
示例#7
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();
  }
示例#8
0
  public void start() {

    // set up the console handler

    console.setHandler(new ConsoleHandler());

    // load the map

    map = MapLoader.loadMap("map_basic.txt");

    // grab some entities

    StaticEntity chip = new StaticEntity();
    chip.setPosition(new Coord(9, 5));
    chip.addTexture(GameContext.getTextureLoader().getTexture("gtest/resources/chipA.png"));
    chip.addTexture(GameContext.getTextureLoader().getTexture("gtest/resources/chipB.png"));
    entities.add(chip);

    // create the player
    player = new Player(new Coord(0, 12));
    player.setMapContext(map);
    entities.add(player);

    // set up camera
    GameContext.getCamera().setFollowing(player);

    // set up openGL

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    // game loop

    while (!Display.isCloseRequested()) {

      Date d = new Date();
      long startTime = d.getTime();

      draw();
      update();
      handleInput();

      d = new Date();
      long endTime = d.getTime();

      try {
        Thread.sleep(50 - (endTime - startTime));
      } catch (Exception e) {
      }

      if ((endTime - startTime) != 0) {
        GameContext.addToLog("fps", "" + 1000 / (endTime - startTime));
      }
    }

    Display.destroy();
  }
示例#9
0
 /* (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 destroyOpenGL() {
    // Delete the shaders
    GL20.glUseProgram(0);
    GL20.glDetachShader(pId, vsId);
    GL20.glDetachShader(pId, fsId);

    GL20.glDeleteShader(vsId);
    GL20.glDeleteShader(fsId);
    GL20.glDeleteProgram(pId);

    // Select the VAO
    GL30.glBindVertexArray(vaoId);

    // Disable the VBO index from the VAO attributes list
    GL20.glDisableVertexAttribArray(0);
    GL20.glDisableVertexAttribArray(1);

    // Delete the vertex VBO
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL15.glDeleteBuffers(vboId);

    // Delete the index VBO
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
    GL15.glDeleteBuffers(vboiId);

    // Delete the VAO
    GL30.glBindVertexArray(0);
    GL30.glDeleteVertexArrays(vaoId);

    Display.destroy();
  }
 @Override
 protected void onTerminated() {
   // GameService.getSoundSystem().unloadAllSounds();
   current_world = null;
   INSTANCE = null;
   Display.destroy();
 }
示例#12
0
  public ExitButton(double x, double y, double width, double height) {
    super(x, y, width, height);

    try {
      exitButtonTex =
          TextureLoader.getTexture("PNG", new FileInputStream(new File("res/startButton.png")));
    } catch (FileNotFoundException e) {
      e.printStackTrace();
      Display.destroy();
      System.exit(1);
    } catch (IOException e) {
      e.printStackTrace();
      Display.destroy();
      System.exit(1);
    }
  }
示例#13
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();
  }
示例#14
0
 private void initGL() {
   try {
     Display.setDisplayMode(new DisplayMode(GS.FRAMEWIDTH, GS.FRAMEHEIGHT));
     Display.setFullscreen(true);
     Display.create();
     Display.setVSyncEnabled(true);
   } catch (LWJGLException e) {
     e.printStackTrace();
     Display.destroy();
     System.exit(1);
   }
   GL11.glEnable(GL11.GL_TEXTURE_2D);
   // GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
   GL11.glClearDepth(1.0f);
   // GL11.glEnable(GL11.GL_DEPTH_TEST);
   // GL11.glDepthFunc(GL11.GL_ADD); //Wenn nicht auskommentiert führt es zu Exception
   GL11.glMatrixMode(GL11.GL_PROJECTION);
   GL11.glViewport(0, 0, GS.FRAMEWIDTH, GS.FRAMEHEIGHT);
   GL11.glOrtho(0, GS.FRAMEWIDTH, GS.FRAMEHEIGHT, 0, 0, 128);
   GL11.glEnable(GL11.GL_BLEND);
   GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
   // GL11.glBlendEquation( BLENDING_EQUATIONS[blendingEquationIndex]);
   GL11.glShadeModel(GL11.GL_FLAT);
   GL11.glMatrixMode(GL11.GL_MODELVIEW);
   GL11.glEnable(GL11.GL_ALPHA_TEST);
   GL11.glAlphaFunc(GL11.GL_GREATER, 0);
   GL11.glCullFace(GL11.GL_BACK);
   glEnable(GL_CULL_FACE);
   glCullFace(GL_BACK);
   GL11.glLoadIdentity();
 }
示例#15
0
  /**
   * 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();
    }
  }
示例#16
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();
  }
示例#17
0
 public void handleInput() {
   if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
     System.out.println("PAUSE");
   }
   if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
     Display.destroy();
   }
 }
示例#18
0
  public Game(boolean host) {
    try {
      if (host) {
        System.out.println("Hosting...");
        server = new ServerSocket(port, 4, InetAddress.getByName(serverIP));
        System.out.println("Ready!\nAwaiting client...");
        client = server.accept();
        System.out.println("Client connected!\nBuffering...");
        out = new ObjectOutputStream(client.getOutputStream());
        in = new ObjectInputStream(client.getInputStream());
        System.out.println("Buffered!\nPinging for 256 bytes...");
        long start = System.currentTimeMillis();
        byte[] ping = new byte[256];
        in.read(ping);
        System.out.println("Latency: " + (System.currentTimeMillis() - start));
        out.writeLong(start);
        out.flush();
        System.out.println("Starting threads...");
        new ThreadSend(world, out);
        new ThreadReceive(world, in);
        System.out.println("Started!\nCreating game world...");
      } else {
        System.out.println("Connecting...");
        socket = new Socket(connectIP, port);
        System.out.println("Connected!\nBuffering...");
        in = new ObjectInputStream(socket.getInputStream());
        out = new ObjectOutputStream(socket.getOutputStream());
        byte[] ping = new byte[256];
        new Random().nextBytes(ping);
        System.out.println("Buffered\nPinging for 256 bytes...");
        out.write(ping);
        out.flush();
        long latency = in.readLong();
        System.out.println("Latency: " + (System.currentTimeMillis() - latency));
        System.out.println("Starting threads...");
        new ThreadReceive(world, in);
        new ThreadSend(world, out);
        System.out.println("Started!\nCreating game world...");
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    try {
      Display.setDisplayMode(new DisplayMode(width, height));
      Display.create();
    } catch (Exception e) {
      e.printStackTrace();
    }

    world.init();

    while (!Display.isCloseRequested()) {
      if (ended) break;
      world.update();
    }

    Display.destroy();
  }
示例#19
0
  /** Do any game-specific cleanup */
  private static void cleanup() {
    // TODO: save anything you want to disk here

    // Stop the sound
    AL.destroy();

    // Close the window
    Display.destroy();
  }
  public void execute() {
    long lastTime = System.nanoTime();
    while (!Display.isCloseRequested()) {
      long deltaTime = System.nanoTime() - lastTime;
      lastTime += deltaTime;
      display(deltaTime);
    }

    Display.destroy();
  }
示例#21
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);
  }
示例#22
0
 /**
  * @param path Path of the .obj file
  * @param index GLUint
  */
 public static void name(String path, int index) {
   int list = glGenLists(index);
   glNewList(list, GL_COMPILE);
   {
     Model m = null;
     try {
       m = OBJLoader.loadModel(new File(path));
     } catch (FileNotFoundException e) {
       e.printStackTrace();
       Display.destroy();
       System.exit(1);
     } catch (IOException e) {
       e.printStackTrace();
       Display.destroy();
       System.exit(1);
     }
     float b;
     //			glColor3f(0.3f, 0.20f, 0.13f);
     b = (float) Math.random();
     glColor3f(b, 0, 0);
     int count = 0;
     glBegin(GL_TRIANGLES);
     for (Face face : m.faces) {
       count++;
       Vector3f n1 = m.normals.get((int) face.normal.x - 1);
       glNormal3f(n1.x, n1.y, n1.z);
       Vector3f v1 = m.vertices.get((int) face.vertex.x - 1);
       glVertex3f(v1.x, v1.y, v1.z);
       Vector3f n2 = m.normals.get((int) face.normal.y - 1);
       glNormal3f(n2.x, n2.y, n2.z);
       Vector3f v2 = m.vertices.get((int) face.vertex.y - 1);
       glVertex3f(v2.x, v2.y, v2.z);
       Vector3f n3 = m.normals.get((int) face.normal.z - 1);
       glNormal3f(n3.x, n3.y, n3.z);
       Vector3f v3 = m.vertices.get((int) face.vertex.z - 1);
       glVertex3f(v3.x, v3.y, v3.z);
     }
     glEnd();
     System.out.println(count);
   }
   glEndList();
 }
 private static void setUpDisplay() {
   try {
     Display.setDisplayMode(new DisplayMode(640, 480));
     Display.setVSyncEnabled(true);
     Display.setTitle("Core Lighting Demo");
     Display.create();
   } catch (LWJGLException e) {
     System.err.println("The display wasn't initialized correctly. :(");
     Display.destroy();
     System.exit(1);
   }
 }
示例#24
0
  private void doRenderLoop() {
    try {
      while (!isDisplayable()) {
        Thread.sleep(50);
      }
      Display.setParent(this);
      Display.setVSyncEnabled(true);
      Display.create();
      mMouseState = new boolean[Mouse.getButtonCount()];
      for (int i = 0; i < mMouseState.length; i++) {
        mMouseState[i] = Mouse.isButtonDown(i);
      }

      // GL11.glsetSwapInterval(1);
      GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
      // gl11.glColor3f(1.0f, 0.0f, 0.0f);
      GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
      GL11.glClearDepth(1.0);
      GL11.glLineWidth(2);
      GL11.glEnable(GL11.GL_DEPTH_TEST);
      if (mScene.getAmbientLight() != null) {
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glLightModel(
            GL11.GL_LIGHT_MODEL_AMBIENT, Color4fLogic.toFloatBuffer(mScene.getAmbientLight()));
      }
      if (mScene.getColorMaterialFace() != JGLColorMaterialFace.UNSET) {
        initMaterial();
      }
      if (mScene.getFogMode() != JGLFogMode.UNSET) {
        initFog();
      }

      Dimension newDim;

      while (!Display.isCloseRequested() && !mCloseRequested) {
        newDim = mNewCanvasSize.getAndSet(null);
        if (newDim != null) {
          GL11.glViewport(0, 0, newDim.width, newDim.height);
          syncViewportSize();
        }
        doRender();
        doMouse();
        doKeys();
        doEye();
        Display.update();
      }

      Display.destroy();
    } catch (InterruptedException | LWJGLException e) {
      e.printStackTrace();
    }
  }
示例#25
0
  public static void main(String[] args) {
    try {
      Display.setDisplayMode(new DisplayMode(640, 480));
      Display.setTitle("Immediate Mode Demo");
      Display.create();
    } catch (LWJGLException e) {
      e.printStackTrace();
      Display.destroy();
      System.exit(1);
    }

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(1, 1, 1, 1, 1, -1);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    while (!Display.isCloseRequested()) {
      glClear(GL_COLOR_BUFFER_BIT);

      glBegin(GL_TRIANGLES);
      {
        glColor3f(1, 0, 0);
        glVertex2f(-0.5f, -0.5f);
        glColor3f(0, 1, 0);
        glVertex2f(0.5f, -0.5f);
        glColor3f(0, 0, 1);
        glVertex2f(0.5f, 0.5f);
      }
      glEnd();

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

    Display.destroy();
    System.exit(0);
  }
示例#26
0
  public Main() {
    try {
      Display.setDisplayMode(new DisplayMode(800, 600));
      Display.create();

      while (!Display.isCloseRequested()) {
        Display.update();
      }

      Display.destroy();
    } catch (LWJGLException e) {
      e.printStackTrace();
    }
  }
示例#27
0
  private void startDisplayLoop() {
    while (!Display.isCloseRequested()) {
      GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

      checkInput();
      applyPhysics();

      drawStuff();

      endThisLoop();
    }
    endProgram();
    Display.destroy();
  }
 private static void setUpDisplayLists() {
   bunnyDisplayList = glGenLists(1);
   glNewList(bunnyDisplayList, GL_COMPILE);
   {
     Model m = null;
     try {
       m = OBJLoader.loadModel(new File(MODEL_LOCATION));
     } catch (FileNotFoundException e) {
       e.printStackTrace();
       Display.destroy();
       System.exit(1);
     } catch (IOException e) {
       e.printStackTrace();
       Display.destroy();
       System.exit(1);
     }
     glColor3f(0.4f, 0.27f, 0.17f);
     glBegin(GL_TRIANGLES);
     for (Face face : m.faces) {
       Vector3f n1 = m.normals.get((int) face.normal.x - 1);
       glNormal3f(n1.x, n1.y, n1.z);
       Vector3f v1 = m.vertices.get((int) face.vertex.x - 1);
       glVertex3f(v1.x, v1.y, v1.z);
       Vector3f n2 = m.normals.get((int) face.normal.y - 1);
       glNormal3f(n2.x, n2.y, n2.z);
       Vector3f v2 = m.vertices.get((int) face.vertex.y - 1);
       glVertex3f(v2.x, v2.y, v2.z);
       Vector3f n3 = m.normals.get((int) face.normal.z - 1);
       glNormal3f(n3.x, n3.y, n3.z);
       Vector3f v3 = m.vertices.get((int) face.vertex.z - 1);
       glVertex3f(v3.x, v3.y, v3.z);
     }
     glEnd();
   }
   glEndList();
 }
示例#29
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);
  }
 public PongGame() {
   setUpDisplay();
   setUpOpengGL();
   setUpEntities();
   setUpTimer();
   while (isRunning) {
     render();
     logic(getDelta());
     input();
     Display.update();
     Display.sync(60);
     if (Display.isCloseRequested()) {
       isRunning = false;
     }
   }
   Display.destroy();
 }