LibGDX Packaging/wrapping exe from jar

I have my LibGDX game that launches and looks how I expect it to through Eclipse. When I package/build the game and launch the .jar file from my desktop, it also launches and looks how I expect it to.

However, when I use Launch4J to wrap it in an executable, it builds and launches okay, however, it’s super zoomed in to the top left quarter of the game screen (so basically you can see a quarter of the game screen starting from the origin).

My DesktopLauncher code is this:
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.addIcon(“artwork/logos/GoldenAgeIcon.png”, FileType.Internal);
config.title = “GOLDENAGE”;
config.foregroundFPS = GameAttributeHelper.FRAMES_PER_SECOND;
config.vSyncEnabled = true;
config.width = LwjglApplicationConfiguration.getDesktopDisplayMode().width;
config.height = LwjglApplicationConfiguration.getDesktopDisplayMode().height;
config.fullscreen = true;
new LwjglApplication(new MyGame(), config);

Has anyone has this problem before? I feel like the problem has to lie in Launch4J, since the regular .jar file works just fine.

I have nothing specifically set to do this in Launch4J. Any ideas?

Wow, I figured out my display was scaled to 250 percent. When I scale it back down to 100 percent, the .exe looks as expected. But I can’t see any of the icons on my computer because they’re too small.

Can I combat this somehow so the visible game screen will scale itself and not also zoom into 250 percent?

This problem is due to HiDPI settings. I suspect you’re using LWJGL2.x with libgdx which knows nothing about the modernfangled world of 4K monitors, and Windows unhelpfully decides to scale the viewport. It’s easy to fix though: right click on the final exe and you’ll see in its Properties a Compatibility tab:


Click on the Change high DPI settings button and you get this:


I don’t think there’s a launch4j option that’ll set this on the executable automatically unfortunately.

Cas :slight_smile:

1 Like

Yes! That worked like a charm. I don’t think I would have ever realized that. Thanks @princec very much appreciated :slight_smile:

1 Like