private void executeWindowRunnablesAndWait() {

    if (windowRunnablesWait == null) return;

    synchronized (SYNC) {
      executedWindowRunnablesWait = windowRunnablesWait;
    }
    executedWindowRunnablesWait.run();
    executedWindowRunnablesWait = null;
    windowRunnablesWait = null;
  }
Example #2
0
  void renderLoop() {
    long startTime = System.currentTimeMillis() + 5000;
    long fps = 0;

    while (glfwWindowShouldClose(window.handle) == GLFW_FALSE) {
      Runnable event;
      while ((event = events.poll()) != null) event.run();

      try {
        display();
      } catch (Exception e) {
        e.printStackTrace();
        break;
      }

      glfwSwapBuffers(window.handle);

      if (startTime > System.currentTimeMillis()) {
        fps++;
      } else {
        long timeUsed = 5000 + (startTime - System.currentTimeMillis());
        startTime = System.currentTimeMillis() + 5000;
        log(
            String.format(
                "%s: %d frames in 5 seconds = %.2f",
                getPlatformInfoStringUTF8(platform, CL_PLATFORM_VENDOR),
                fps,
                fps / (timeUsed / 1000f)));
        fps = 0;
      }
    }

    cleanup();

    window.signal.countDown();
  }