Skip to content

Instantly share code, notes, and snippets.

@crykn
Last active September 2, 2024 16:50
Show Gist options
  • Save crykn/eb37cb4f7a03d006b3a0ecad27292a2d to your computer and use it in GitHub Desktop.
Save crykn/eb37cb4f7a03d006b3a0ecad27292a2d to your computer and use it in GitHub Desktop.
How to switch to libGDX's LWJGL3 backend

How to switch your libGDX project to LWJGL 3


--- This guide is now available on libgdx.com. Check it out here. If you have any questions, join us on Discord! ---


  1. To switch to libGDX's LWJGL 3 backend, open your root build.gradle file and replace the LWJGL backend dependency:
api "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"

with the LWJGL 3 backend dependency:

api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"

Make sure to refresh your Gradle dependencies in your IDE.

  1. Next, you need to fix up your DesktopLauncher class. It is located in your desktop project and should look something like this:
public class DesktopLauncher {
   public static void main (String[] arg) {
      LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
      new LwjglApplication(new MyGdxGame(), config);
   }
}

You’ll need to change it to this:

public class DesktopLauncher {
   public static void main (String[] arg) {
      Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
      new Lwjgl3Application(new MyGdxGame(), config);
   }
}

Common issues:

  • On macOS, the LWJGL 3 backend is only working when the JVM is run with the -XstartOnFirstThread argument. This can typically be done in the Launch/Run Configurations of your IDE. Further information can be found here.
  • If you are using gdx-tools and the lwjgl3 backend in the same project, you need to modify your gdx-tools dependency like this:
    compile ("com.badlogicgames.gdx:gdx-tools:$gdxVersion") {
       exclude group: 'com.badlogicgames.gdx', module: 'gdx-backend-lwjgl'
    }
    
    The cause of this is described here.
@crykn
Copy link
Author

crykn commented Jan 23, 2022

Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment