示例#1
0
文件: Main.java 项目: Osoldier/Vox
 private void render() {
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   engine.Render();
   int error = glGetError();
   if (error != GL_NO_ERROR) System.out.println("Error: " + GLUtil.getErrorString(error));
   glfwSwapBuffers(window);
 }
示例#2
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();
  }
示例#3
0
文件: Main.java 项目: Osoldier/Vox
 private void update() {
   engine.Update();
   glfwPollEvents();
 }