Пример #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();
  }
Пример #2
0
  public void addWindow(final String id, final Lwjgl3Application app) {
    if (app.autoloop) // cannot have a running loop
    return;

    Thread thisThread = Thread.currentThread();

    if (thisThread == mainThread) {
      if (getWindow(id) == null) {
        app.id = id;
        queueWindows.add(app);
      }
    } else {
      Runnable run =
          new Runnable() {

            @Override
            public void run() {
              if (getWindow(id) == null) {
                app.id = id;
                queueWindows.add(app);
              }
            }
          };
      postMainRunnable(run);
    }
  }
Пример #3
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();
      }
    }
  }
Пример #4
0
  private void start() {

    running = true;
    thread = new Thread(this, "ContinuousWindow");
    thread.start();
  }