Building libGDX for Desktop and fixing slow FPS

I previously posted how to build libGDX for web. Now with the end of the LibGDX 2018 Game Jam nearing it’s time to post about building for Desktop.

You want to ensure you have a Desktop launcher set up like the above image.
The important parts include choosing Desktop for the Use Classpath of Module, and that you point the Working Directory to your android/assets folder.

(Make sure you go into your DesktopLauncher and set the width and height of the config to your desired resolution.)

And you’re good to go! Except…

What to do when libGDX’s build for Desktop is too slow (Framerate is slow)

It’s happened too many times. My build for Android is super speedy, as is mine for HTML. But the Desktop runs at a frame rate of 30 or so.

After stuffing around with the settings and googling, the reason is because vSynchEnabled is enabled by default in the Desktop Configuration.

Don’t ask me what it does, but setting this value to false makes everything run buttery smooth again.

Play around with the settings to define your desktop configuration, and now you’re good to go.

public class DesktopLauncher {
   public static void main (String[] arg) {
      LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
      config.title = "Icebergs";
      config.width = 400;
      config.height = 600;
      config.resizable = false;
      config.vSyncEnabled = false;
      new LwjglApplication(new Main(), config);
   }
}

My code after tinkering with the settings.

After the build is complete, you can create a native application using a jar bundling tool libGDX’s Packr.

But that’s for another time. For now, I have to submit that Game Jam game…

Leave a Reply