How to set the application icon for a libGDX desktop application?

João Pinto picture João Pinto · Aug 15, 2013 · Viewed 12.7k times · Source

I am trying to setup an application icon from the -desktop specific class with:

package org.osgameseed.games.animalflip;

import com.badlogic.gdx.Files;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;

public class Main {
    public static void main(String[] args) {
        LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
        cfg.title = "AnimalFlip";
        cfg.useGL20 = false;
        cfg.width = 800;
        cfg.height = 600;
        cfg.addIcon("data/ic_launcher.png", Files.FileType.Internal);

        new LwjglApplication(new AnimalFlipGame(), cfg);
    }
}

The icon is not set (at least on Linux), any idea on how to set it ?

Answer

BennX picture BennX · Aug 15, 2013

Take a look into the api (addIcon(...)):

Adds a window icon. Icons are tried in the order added, the first one that works is used. Typically three icons should be provided: 128x128 (for Mac), 32x32 (for Windows and Linux), and 16x16 (for Windows).

Maybe your icon has the wrong dimensions, so it won't get set. Else it should work!

Just to mention you just set the small icon in the left upper edge (if the application is started) with it not the icon you would see at the desktop!
the small icon