diff --git a/src/java/org/lwjgl/opengl/Display.java b/src/java/org/lwjgl/opengl/Display.java index 76240b94..271711ce 100644 --- a/src/java/org/lwjgl/opengl/Display.java +++ b/src/java/org/lwjgl/opengl/Display.java @@ -43,6 +43,7 @@ package org.lwjgl.opengl; * @author foo */ +import java.nio.ByteBuffer; import java.nio.FloatBuffer; import java.util.Arrays; import java.util.HashSet; @@ -813,4 +814,21 @@ public final class Display { public static String getVersion() { return display_impl.getVersion(); } + + + /** + * Sets one or more icons for the Display. + * + * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform. + * + * @param icons Array of icons in RGBA mode + * @return number of icons used. + */ + public static int setIcon(ByteBuffer[] icons) { + return display_impl.setIcon(icons); + } } diff --git a/src/java/org/lwjgl/opengl/DisplayImplementation.java b/src/java/org/lwjgl/opengl/DisplayImplementation.java index 5aa051b9..7450c7f7 100644 --- a/src/java/org/lwjgl/opengl/DisplayImplementation.java +++ b/src/java/org/lwjgl/opengl/DisplayImplementation.java @@ -230,4 +230,18 @@ public interface DisplayImplementation { public void bindTexImageToPbuffer(PeerInfo handle, int buffer); public void releaseTexImageFromPbuffer(PeerInfo handle, int buffer); + + /** + * Sets one or more icons for the Display. + * + * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform. + * + * @param icons Array of icons in RGBA mode + * @return number of icons used. + */ + public int setIcon(ByteBuffer[] icons); } diff --git a/src/java/org/lwjgl/opengl/LinuxDisplay.java b/src/java/org/lwjgl/opengl/LinuxDisplay.java index 387390ee..659c1c5e 100644 --- a/src/java/org/lwjgl/opengl/LinuxDisplay.java +++ b/src/java/org/lwjgl/opengl/LinuxDisplay.java @@ -436,4 +436,32 @@ final class LinuxDisplay implements DisplayImplementation { public void releaseTexImageFromPbuffer(PeerInfo handle, int buffer) { throw new UnsupportedOperationException(); } + + + /** + * Sets one or more icons for the Display. + * + * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform. + * + * @param icons Array of icons in RGBA mode + * @return number of icons used. + */ + public int setIcon(ByteBuffer[] icons) { + for (int i=0;i + *
  • On Windows you should supply at least one 16x16 icon and one 32x32.
  • + *
  • Linux (and similar platforms) expect one 32x32 icon.
  • + *
  • Mac OS X should be supplied one 128x128 icon
  • + * + * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform. + * + * @param icons Array of icons in RGBA mode + * @return number of icons used. + */ + public int setIcon(ByteBuffer[] icons) { + int size = 0; + int biggest = -1; + + for (int i=0;i size) { + biggest = i; + size = icons[i].limit(); + } + } + + if (biggest == -1) { + return 0; + } + + int width; + int height; + + width = height = (int) Math.sqrt(size); + int[] imageData = icons[biggest].asIntBuffer().array(); + + BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); + img.setRGB(0, 0, width, height, imageData, 0, width); + frame.setIconImage(img); + + return 1; + } } diff --git a/src/java/org/lwjgl/opengl/Win32Display.java b/src/java/org/lwjgl/opengl/Win32Display.java index 5c6e0d1e..6d27b7a3 100644 --- a/src/java/org/lwjgl/opengl/Win32Display.java +++ b/src/java/org/lwjgl/opengl/Win32Display.java @@ -156,4 +156,44 @@ final class Win32Display implements DisplayImplementation { public void releaseTexImageFromPbuffer(PeerInfo handle, int buffer) { ((Win32PbufferPeerInfo)handle).releaseTexImageFromPbuffer(buffer); } + + + /** + * Sets one or more icons for the Display. + * + * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform. + * + * @param icons Array of icons in RGBA mode + * @return number of icons used. + */ + public int setIcon(ByteBuffer[] icons) { + boolean done16 = false; + boolean done32 = false; + int used = 0; + + for (int i=0;i