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); } }
/** 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(); }