Toggle fullscreen in-game

I’ve searched wiki and forums, but nothing works. I’ve binded F11 so it will toggle fullscreen, but can’t properly make it work (doesn’t change from windowed to fullscreen and vice versa). Tried in my UpdateSettings() method:

[java]settings.setFullscreen(fullscreen);[/java]



Didn’t work - it was still windowed.



So I went a bit more complicated route:

[java]AppSettings st = settings;

st.setFullscreen(fullscreen);

setSettings(st);[/java]

But this didn’t work either. Now I’m out of ideas how to make fullscreen work within game (without restarting). It is certainly possible, but I just don’t know how to do that.

Your ability to search is pretty bad, I think:





Note the search terms I used which are about as exactly straight forward as I think one could get and that the VERY first link has exactly the info needed.

I’ve used “fullscreen” without quotes, but with no results, then I used “toggle fullscreen” also without quotes. But still haven’t got any useful info.



Yeah, I guess terms you used were straightforward for novice user trying to get FULLSCREEN to TOGGLE.

Dude, you should go to the doctor, you might have had a stroke. 30 minutes ago you still knew you wanted to apply the application settings:


@dariuszg-jagielski said:
I've searched wiki and forums, but nothing works. I've binded F11 so it will toggle fullscreen, but can't properly make it work (doesn't change from windowed to fullscreen and vice versa). Tried in my UpdateSettings() method:
[java]settings.setFullscreen(fullscreen);[/java]

Didn't work - it was still windowed.

So I went a bit more complicated route:
[java]AppSettings st = settings;
st.setFullscreen(fullscreen);
setSettings(st);[/java]
But this didn't work either. Now I'm out of ideas how to make fullscreen work within game (without restarting). It is certainly possible, but I just don't know how to do that.
@dariuszg-jagielski said:
I've used "fullscreen" without quotes, but with no results, then I used "toggle fullscreen" also without quotes. But still haven't got any useful info.

Yeah, I guess terms you used were straightforward for novice user trying to get FULLSCREEN to TOGGLE.


Here is the way I see it going normally:

"Hmmm... looks like I can set the fullscreen on the app settings."

"Gee, that doesn't work. I wonder why my app settings aren't changing."

"Let me search for 'app settings changing'"

I think you try to bring too much knowledge to it, actually. You out think the search.

It’s worth reading the tutorials thoroughly, almost everything is documented there with examples and descriptions.

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:intermediate:appsettings (This has your answer in the first sentence)



You will want a decent understanding of the architecture and workflow of the engine to help solve your problems. Not doing that now will just make things harder later on when you try to implement more difficult features.

I frequently head back to the tutorials to get a solid foundation again of what I am working on. It helps me more in the long-run.

@dariuszg-jagielski Here’s the code I use for that kind of stuff:


settings.setXxx (...);
setSettings (settings);
restart (); // I think this is what you missed
saveSettings (); // To persist for next program start

A tip: Mention what sources you already consulted, that's going to give you less "educational" flames.
The advice on reading the jme3 sources and docs is still very valid, jme3 is far too complex to be used via trial&error.
My approach to docs is to first scan everything with squinted eyes so I know what topics are covered; whenever I start coding, I re-read those pages relevant to the task.
I also tend to single-step through library code (i.e. jme3 code in this case) just to see how the internals work. Actually that's how I stumbled over restart(), I missed that one in the docs, too.

HTH
3 Likes