Fix corrupted window icon

This commit is contained in:
Raven Szewczyk committed 2023-01-25 13:07:15 +00:00
1 parent ef89e1eea7
commit d0aa511c4a
2 files changed
+8 -6

No files matched your search

+7 -5
View File
@@ -416,14 +416,16 @@ public class Display {
return 0;
}
GLFWImage.Buffer glfwImages = GLFWImage.calloc(icons.length);
ByteBuffer[] nativeBuffers = new ByteBuffer[icons.length];
for (int icon = 0; icon < icons.length; icon++) {
ByteBuffer iconBytes = org.lwjgl.BufferUtils.createByteBuffer(icons[icon].capacity());
iconBytes.put(icons[icon]);
int dimension = (int) Math.sqrt(iconBytes.limit() / 4D);
if (dimension * dimension * 4 != iconBytes.limit()) {
nativeBuffers[icon] = org.lwjgl.BufferUtils.createByteBuffer(icons[icon].capacity());
nativeBuffers[icon].put(icons[icon]);
nativeBuffers[icon].flip();
int dimension = (int) Math.sqrt(nativeBuffers[icon].limit() / 4D);
if (dimension * dimension * 4 != nativeBuffers[icon].limit()) {
throw new IllegalStateException();
}
glfwImages.put(icon, GLFWImage.create().set(dimension, dimension, iconBytes));
glfwImages.put(icon, GLFWImage.create().set(dimension, dimension, nativeBuffers[icon]));
}
GLFW.glfwSetWindowIcon(getWindow(), glfwImages);
glfwImages.free();