So, I was designing a GUI and decided to make it scale according to the current screen’s resolution. Upon doing that I realized that I couldn’t get the current AppSettings from a AppState. Is there a way to access it, or should I simply pass the AppSettings in the constructor?
but it provides no getter.
I think this is to prevent a class to change the settings during runtime.
I would pass the resolution as parameter to your Appstate
Do you just want to know the screen size? You don’t need app settings for that (and because it can be changed at runtime without updating the actual app it could lie to you, also).
Application.getCamera().getWidth() and getHeight().
Do you really want the “screen” (the full desktop), or rather the “display” (the area that is actually assigned to your application)? I guess you want the latter.
Then these method from lwjgl will help:
Using these may cause extra problems when migrating to newer JME versions. JME itself maybe hard to handle when upgrading, but that is another story. But if you just want to try JME with LWJGL 3, this doesn’t work.
…if you just want the size of your rendered display then that’s exactly what app.getCamera().getWidth() and app.getCamera().getHeight() will tell you. …which I already posted.
If you want to scale a UI, then those are the values you want. Not the ones in AppSettings.
Sorry for late reply, but thanks for your help guys! At the moment I pass the AppSettings to my AppState and simply get the width and height values. However, that doesn’t look “clean”, if you guys understand me. I’ll probably use @pspeed solution: to get the camera’s width and height.
But, If i mess with the camera’s frustum values, will those values remain the same?
@Pesegato what I need is the resolution the player chooses at start, when the jME settings dialog shows up.
Also, can’t this be changed? Most of games I know for PC (if not all of them) allow the user to change graphics options during runtime. I will implement this in my game, so wouldn’t be easier for AppStates to have access to the AppSettings, rather than creating new ones and applying them?
On a side note (and since this way I won’t need to create another thread), is it possible to make the jME window manually resizable? Like pushing the borders and/or allow to maximize the window?
Camera width/height is the width of the display as JME sees it. The frustum affects the projection matrix but width/height don’t change unless the display size changes… which is what you want.