Suggestion: DisplaySystem.setIcon()

Hi!



I found a missing method from lwjgl to set the window icon, on the jme's DisplaySystem.



Is nothing important, just a detail, but I feel like suggesting it to be included. I don't know if it wasn't done about design decisions (that is, a feature not implemented as other implementations won't allow it). So if it was, just ignore me :wink:



Just needs to be modified the DisplaySystem abstract class, and both existing implementations: LWJGLDisplaySystem and DummyDisplaySystem. On the former, just needs to call Display.setIcon() from lwjgl.


I doubt it was omitted on purpose. Quickest way to get it in, would of course, to give us the code :slight_smile:

But you can also enter an issue in the issue tracker, or hope someone will pick it up here…

Not so important to be an issue :wink: But here's goes the code if anyone wants to add it:



DisplaySystem.java

public abstract void setIcon(ByteBuffer[] iconData);



LWJGLDisplaySystem.java

public void setIcon(ByteBuffer[] iconData) {
    Display.setIcon(iconData);
}



DummyDisplaySystem.java

public void setIcon(ByteBuffer[] iconData) {
}

Yeah, but that's the easy part. Does LWJGL have a Javadoc we can copy, or are they as lazy as you?

Real programmers doesn't need comments, you know :stuck_out_tongue:



I took the javadoc from lwjgl (copy+paste).



DisplaySystem.java


/**
 * Sets one or more icons for the Display.
 * <ul>
 * <li>On Windows you should supply at least one 16x16 icon and one 32x32.</li>
 * <li>Linux (and similar platforms) expect one 32x32 icon.</li>
 * <li>Mac OS X should be supplied one 128x128 icon</li>
 * </ul>
 * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform.
 * <p>
 * <b>NOTE:</b> The display will make a deep copy of the supplied byte buffer array, for the purpose
 * of recreating the icons when you go back and forth fullscreen mode. You therefore only need to
 * set the icon once per instance.
 *
 * @param icons Array of icons in RGBA mode
 * @return number of icons used, or 0 if display hasn't been created
 */
public abstract int setIcon(ByteBuffer[] iconData);



LWJGLDisplaySystem.java


/** 
 * @see com.jme.system.DisplaySystem#setIcon(java.nio.ByteBuffer[])
 */
public int setIcon(ByteBuffer[] iconData) {
    return Display.setIcon(iconData);
}



DummyDisplaySystem.java


/*
 * @see com.jme.system.DisplaySystem#setIcon(java.nio.ByteBuffer[])
 */
public int setIcon(ByteBuffer[] iconData) {
    return 0;
}



On second thoughs, maybe we should add some more generic method for that, as this is the 'lwjgl' way.

If you don't mind, I'll prepare some code to pass just java images, and then take them and do the processing on the implementation. It will be more 'standard'.

edit: just read your edit after posting XD Yes, I'll do that then!

Great! It shouldn't be too much extra work. The only problem I can think of is not all Image are RGBA, though you can check the type (getType() == RGBA8888).



RGB888 to RGBA8888 conversion would be a bonus, but there should be an ImageUtils class or something like that to do those things. And typically you'll want alpha values for your icons anyway, so I think doing a check to see it's RGBA8888 is enough

Yes, I'll get this in soon. I assume you tested it.



Hm… I think we need some official jME icons now :slight_smile:

llama said:

Hm.. I think we need some official jME icons now :)


We have one, the one that is used for WebStart.

There are some art pieces in the work we may be able to use…

How about this:







I made quick work of it, but if you’ve got a magnifying glass perhaps you can tell it’s a monkey (specifically ripped from the logo in the upper right corner of your screen). :-p



darkfrog

@Badmi: Unfortunatly that's 64x64, the one size we don't need. And based on the old logo too.



I have the code in my local copy now, I created a new ImageUtils class to handle the conversion. Tora, do you have a real name I can use for the @author tag or do you prefer "Tora"?



Darkfrog's mini icon look ok, and while the smallest one is probably the most difficult one to get right, we need the bigger sizes too. It's probably best to create them from the original SVG file (I guess?), which I can't seem to find (the one in the offtopic forum misses the drop shadow)



Renanse, are you hinting at some other new art?



Another question… should we let SimpleGame load these logo's by default perhaps? :slight_smile:


I think having it set by default is fine (after all, that's what LWJGL does anyway) for any jME game and it can be explicitly defined to override it.



darkfrog



My try.. a bit easier to recognize as a monkey on my 1600x1200 screen, but he looks a bit ill now ://

My try:







I’ve pm’ed my confidential and ultra secret real name :stuck_out_tongue_winking_eye:



And I like the idea of setting a default monkey icon :slight_smile:

If people don't want a monkey as the icon I would be happy to submit a more appealing icon…such as a frog icon. :-p



darkfrog

Ok, it's in CVS.



Eh, I admit not testing it that well yet

But I figure we'll do that with this jME icon stuff…

I've only tested on windows (don't have a linux nor mac box around) the code I posted, and it works fine with images that are being loaded as rgba8888 & rgb888 formats (I tried png with transparency with 24  & 8 bits color depth, and without transparency).



The cvs commit still doesn't shows here, looks like it takes a while to take effect :wink: I'll give you feedback when I got to update.

Got the update. Tested it. Works fine here (Windows XP SP2) :slight_smile:

I've just downloaded the latest CVS, and this doesn't seem to work for me:


    [javac] C:ProjectsjmesrccomjmesystemlwjglLWJGLDisplaySystem.java:526: cannot find symbol
    [javac] symbol  : method setIcon(java.nio.ByteBuffer[])
    [javac] location: class org.lwjgl.opengl.Display
    [javac]         Display.setIcon(iconData);


Not a huge issue, I just commented out the line and it builds fine - I just have to remember not to use that method.

Perhaps the lwjgl version isn't up to date?

http://www.lwjgl.org/javadoc/org/lwjgl/opengl/Display.html#setIcon(java.nio.ByteBuffer[])



Seems like you're using an old LWJGL version…