Switching from LWJGL2 to LWJGL3. Experiences and Questions

Hi, we decided to switch our game from LWJGL2 to LWJGL3. Let me share some experiences, and start a little bit of discussion: We tried on Windows 10 and Mac OS-X.

  1. We needed a jre with Version greater than 1.8. Adopt Open JDK 11 worked well.
  2. On Windows, it was not a too big issue. Mainly, you have to substitute everything with Display. The Migration guide helped: 2.6.6 LWJGL3 migration · LWJGL/lwjgl3-wiki Wiki · GitHub
  3. Now to Mac-OSX:
    3.1 Take care to have only one thread until the game starts, and avoid everything with awt, swing etc.
    3.2. Use the option -XstartOnFirstThread. In eclipse there is in addition a checkbox for this. I needed both.
    3.3 Do not call GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() to get the available fullscreen modes
    3.4 Do not use the OSX adapter settings to define the behavior of the OS-X menus.
    3.5 Do not use Toolkit.getDefaultToolkit().getScreenSize() to find out the screen size
    3.6 Do not use settings.setIcons(…) for the AppSettings

These were the pitfalls where we searched quite long … :wink:

Now some points for discussion, maybe somebody can help. Everything for Mac OS-X:

  1. How to set the the menus in the OSX adapter. It is not possible before the game starts, and in the game, the calls (also in a separate thread) freezed the game.
  2. How to obtain the screensize of the monitor? The Toolkit things do not work during the game.
  3. How to obtain the available fullscreen display modes? 3.3. from above does not work also during the game run, we also tried in a different thread.

Thanks.

4 Likes

Just in case it wasn’t clear, these:

And this:

Are the same thing, basically… or at least all of the first ones are covered under “don’t use AWT”.

In case anyone reading this is trying to connect the dots.

I don’t know any answers to your questions, though… it seems like Apple is getting harder and harder to support and some (non-JME) game devs are just deciding to drop support for it. Kind of sad.

1 Like

In case interested to try this, there is an on going JEP to implement a Java 2D internal rendering pipeline for macOS using the Apple Metal.

http://openjdk.java.net/jeps/382

https://wiki.openjdk.java.net/display/lanai/Main

early access builds
https://jdk.java.net/lanai/

4 Likes

Very useful, many thanks.

Just to add another couple obstacles I recently hit.

  1. It didn’t dawn on me that showing the initial appsettings default dialog would do AWT/Swing
  2. In my two catalina boxes - when we inited the graphics it would fail and I would be thrown back into a GUI log in prompt. Upgrading to Big Sur fixed it.