Nifty GUI with a custom resolution

Does some know a way to use Nifty GUI in a custom resolution (in my case 800x480 to suits Android phones) or even to use it independently from resolution (would be even better).

Thx !

from niftys perspective width/height of the screen is determined by asking the specific RenderDevice you use (probably RenderDeviceJME3 or something). If you find a way to trick that one to different resolutions then Nifty should not make any problems.

However @void256 I think the reasons are slightly more complicated than that.

Nifty GUI was not intended to be scaled … Simply putting in a hack in jME3 to report the wrong resolution isn’t going to solve much I think.

I think void meant to have the RenderDevice to actually use that weird resolution. Not lie about it. :wink: That’s how I read it.

The RenderDevice reports whatever you have your AppSettings resolution set to … in the case of android devices its just the device’s native resolution

@Momoko_Fan: From the point of view of Nifty the screen resolution is always what renderDevice.getWidth() and renderDevice.getHeight() return. There is no other way. When the native resolution of the device is returned all should be well.

It would be the same for a window on the desktop that can be resized. The window size in that case is - again from Niftys point of view . renderDevice.getWidth()/getHeight(). Since Nifty does currently not autodetect changes in the screen resolution the user of Nifty/JME would need to manually call nifty.resolutionChanged() to notify Nifty about the new window resolution.

Nifty GUI was not intended to be scaled, that is right but then again, you would get the same fontsize on a bigger canvas. why not?

uhm, on a second thought I wonder why Nifty does not autodetect changes to width/height of the RenderDevice tho … wouldn’t be that hard at all :smiley:

So I only have to change resolution in AppSettings ? I’m ont sure I understand everything…

I’ve tried changing AppSettings but no resize happened. Another guess ?

not sure when you change them but when you change the screen resolution while Nifty is running you need to trigger Nifty with nifty.resolutionChanged() so that it can update itself to the new resolution. (This method is pretty new tho. It might still be missing from jme builds).

besides that I don’t know what might be wrong tho :slight_smile:

This method seems to be what I’m looking for but to use it I need to use the latest Nifty jars and those jars make my app crash (as I said here :

Well, I downloaded the latest Nifty jar (7 june 2011), succeeded to make the GUI display and I tried to insert nifty.resolutionChanged() into my app’s code but either I do it the wrong way or it’s bugging because it doesn’t do anything.

I tried it first in the simpleInitApp() method and then in the simpleUpdate() one. Both aren’t working.

Is there something I’m doing wrong ?

That “nifty.resolutionChanged()” call will only notify Nifty that you’ve set a new resolution. It will simply refresh the internal values for width/height and relayouts the screen using the new resolultion. Setting a new resolution is up to you :slight_smile:

In case you’re already doing that, well, it might be that the (Nifty) RenderDevice implementation for JME3 does not update when you set a new resolution. From a quick look at the code it looks right tho.

Setting a new resolution is up to you

Oh I didn't get this part :).

Do you have an example of an existing resolution so I can inspire me ?

Thx !