Exemplo n.º 1
0
  /** Main Loop for GLFW. This call will block <br> */
  public void start() {
    mainThread = Thread.currentThread();
    windowThread.start();
    running = true;
    while (running) {
      executeMainRunnables();

      for (int i = 0; i < queueWindows.size; ) {
        final Lwjgl3Application app = queueWindows.removeIndex(i);
        i--;

        Runnable run =
            new Runnable() {
              @Override
              public void run() {
                glfwMakeContextCurrent(0);
                jumpLoop = true;
              }
            };
        postWindowRunnableAndWait(run);

        initWindow(app);
        glfwShowWindow(app.graphics.window);

        Runnable run2 =
            new Runnable() {
              @Override
              public void run() {
                initContext(app);
                windows.add(app);
                tmpfirst = true;
              }
            };
        postWindowRunnable(run2);
        jumpLoop = false;
        break;
      }

      if (tmpfirst && windows.size == 0) {
        running = false;
      }

      glfwWaitEvents();
    }
    try {
      windowThread.join();
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    glfwTerminate();
    if (errorCallback != null) errorCallback.release();
  }
Exemplo n.º 2
0
  public void postWindowRunnableAndWait(Runnable runnable) {
    synchronized (SYNC) {
      windowRunnablesWait = runnable;
    }

    while (windowRunnablesWait != null) {
      try {
        Thread.sleep(100);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }