针对不同平台,在 LWJGL 3.1 中更改 GLFW 3 Window 图标的不同方式
Different ways, for different platforms, to change GLFW 3 Window Icon in LWJGL 3.1
我正在创建一个适用于 LWJGL 3 的游戏引擎。
我正在创建一个名为 class 的 'FrameManager' 希望句柄 Window 输入(如大小、位置等),但我已经在许多网站、文档等中查找过,而且我没有找到如何创建希望设置 Window 图标的简单方法。
首先,我找到了一个 GLFW 3 方法:glfwSetWindowIcon(frameId, images);
但它似乎不适用于 macOS Sierra 1.12(我暂时无法在 Window 上进行测试)。
以下是我如何使用此方法:
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();
我尝试了 before/after Window Creation/Show 但在 macOS Sierra 10.12 中没有任何反应(没有错误,但没有图标)。
所以,我认为它适用于 Window 但不适用于 Mac。
我寻找了一个 Apple 解决方案,然后找到了 2 种方法,但它不起作用:(
首先,在 VM 启动参数中添加:-Xdock:icon=/path/myIcon.png
但什么也没发生:(
我也试过了:
Application.getApplication().setDockIconImage(Image img);
它不创建图标并中断线程(此时线程被阻塞)。
我知道 Application Bundle 存在,但是真的没有其他解决方案吗?
感谢您的帮助!
祝你有美好的一天!
根据 the GLFW documentation,GLFW 图标 API 不起作用,请参阅 API 文档中的 "Remarks"。
它提到您应该使用捆绑图标来设置停靠栏图标。
我正在创建一个适用于 LWJGL 3 的游戏引擎。
我正在创建一个名为 class 的 'FrameManager' 希望句柄 Window 输入(如大小、位置等),但我已经在许多网站、文档等中查找过,而且我没有找到如何创建希望设置 Window 图标的简单方法。
首先,我找到了一个 GLFW 3 方法:glfwSetWindowIcon(frameId, images);
但它似乎不适用于 macOS Sierra 1.12(我暂时无法在 Window 上进行测试)。
以下是我如何使用此方法:
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();
我尝试了 before/after Window Creation/Show 但在 macOS Sierra 10.12 中没有任何反应(没有错误,但没有图标)。
所以,我认为它适用于 Window 但不适用于 Mac。
我寻找了一个 Apple 解决方案,然后找到了 2 种方法,但它不起作用:(
首先,在 VM 启动参数中添加:-Xdock:icon=/path/myIcon.png
但什么也没发生:(
我也试过了:
Application.getApplication().setDockIconImage(Image img);
它不创建图标并中断线程(此时线程被阻塞)。
我知道 Application Bundle 存在,但是真的没有其他解决方案吗?
感谢您的帮助! 祝你有美好的一天!
根据 the GLFW documentation,GLFW 图标 API 不起作用,请参阅 API 文档中的 "Remarks"。
它提到您应该使用捆绑图标来设置停靠栏图标。