コード例 #1
0
ファイル: HelloWorld.java プロジェクト: codemonkeyrich/myGit
  public void run() {
    System.out.println("Hello LWJGL " + Sys.getVersion() + "!");

    try {
      init();
      loop();

      // Release window and window callbacks
      glfwDestroyWindow(window);
      keyCallback.release();
    } finally {
      // Terminate GLFW and release the GLFWerrorfun
      glfwTerminate();
      errorCallback.release();
    }
  }
コード例 #2
0
ファイル: Main.java プロジェクト: MikeJones999/Lwjgl-Project
  @Override
  public void run() {

    init();
    createAndLoadModelAttributes();
    while (running) {
      update();
      render();

      // if window should be closed then exit the loop
      if (glfwWindowShouldClose(window) == GL_TRUE) {
        running = false;
      }
    }

    keyCallback.release();
    loader.cleanUpVBOSandVAOs();
  }
コード例 #3
0
ファイル: Main.java プロジェクト: Osoldier/Vox
  public void run() {
    init();
    engine = new Engine();

    long lastTime = System.nanoTime();
    double delta = 0.0;
    // Amout of nanoseconds in 1/60th of a second
    double ns = 1000000000.0 / 60.0;
    long timer = System.currentTimeMillis();
    int updates = 0;
    int frames = 0;
    while (running) {
      long now = System.nanoTime();
      delta += (now - lastTime) / ns;
      lastTime = now;
      // if delta >= than one then the amount of time >= 1/60th of a second
      if (delta >= 1.0) {
        update();
        updates++;
        delta--;
      }
      render();
      frames++;
      // If a second has passed, we print the stats
      if (System.currentTimeMillis() - timer > 1000) {
        timer += 1000;
        System.out.println(updates + " ups, " + frames + " fps");
        updates = 0;
        frames = 0;
      }
      if (glfwWindowShouldClose(window) == GL_TRUE) running = false;
    }
    engine.CleanUp();
    keyCallback.release();
    sizeCallback.release();
    mouseCallback.release();
    focusCallback.release();
    glfwDestroyWindow(window);
    glfwTerminate();
  }