-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cocoa: Make GLFW work with AWT on macOS
GLFW requires to be called on the main thread. Starting with -XstartOnFirstThread will achieve that. However, when calling into AWT, AWT takes over the run loop, and GLFW is never getting any new events. This commit changes GLFW so its windowing functions can be called on a different thread. The JVM can then be started without -XstartOnFirstThread. Next, we have to give AWT control of the run loop, i.e. by calling Toolkit.getDefaultToolkit() via EventQueue.invokeAndWait. This will setup the run loop and give AWT control. Finally, we can call into glfwInit and consorts, on the JVM main thread, which is NOT the Cocoa main thread. All calls into GLFW get dispatched to the Cocoa main thread in blocking mode. This way GLFW and AWT can live happily side by side. See https://gist.github.com/badlogic/e059fba23d6151ceb82c26f4f4b1470d for a LWJGL3 example.
- Loading branch information
Showing
3 changed files
with
553 additions
and
751 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.