I'm creating a Game Engine that works with LWJGL 3.
I'm creating a class named 'FrameManager' wish handle Window inputs (Like Size, Position, etc) but I've looked for in many web sites, documentation etc, and I didn't find how to create a simple method wish set the Window icon.
First, I found a GLFW 3 method: glfwSetWindowIcon(frameId, images);
But it don't seems to work on macOS Sierra 1.12 (I cannot test on Window for the moment).
Here is how i use this method:
log.debug(" -> Setting Icon...");
final PNGDecoder decoder = new PNGDecoder(new FileInputStream(iconPath));
final int iconWidth = decoder.getWidth();
final int iconHeight = decoder.getHeight();
final ByteBuffer buffer = createByteBuffer(iconWidth * iconHeight * 4);
decoder.decode(buffer, iconWidth * 4, PNGDecoder.Format.RGBA);
buffer.flip();
final GLFWImage image = malloc();
image.set(iconWidth, iconHeight, buffer);
final GLFWImage.Buffer images = malloc(1);
images.put(0, image);
glfwSetWindowIcon(frameId, images);
images.free();
image.free();
I tried it before/after Window Creation/Show but nothing happen in macOS Sierra 10.12 (No Error, but no Icon).
So, i considered that it works on Window but not on Mac.
I looked for an Apple solution, than I found 2 ways, but it doesn't work :(
First, adding this in the VM launch args: -Xdock:icon=/path/myIcon.png
But nothing happen :(
And I also tried that:
Application.getApplication().setDockIconImage(Image img);
It doesn't create an icon and interrupt the Thread (Thread is blocked at this moment).
I known that Application Bundle exists, but is-there really no other solution ?
Thanks for your help! Have a nice day!
According to the GLFW documentation the GLFW icon API does not work, see the "Remarks" in the API documentation.
It mentions that you should use the bundles icon to set the dock bar icon.