Edit: see my answer for the missing part (as in title)
I am working on a game using LibGDX. It should support Mac, Linux, Windows, IOS and Android.
I am developing on Mac OS High Sierra (MacBook Pro 13' early 2011)
Unfortunately I stumbled across a problem already when checking performance. There are huge FPS drops when using the libgdx fullscreen method. BUT...
When I start my Application in Windowed Mode, drawing nothing but an FPS counter I have 59/60 fps with the Frame being as large as it can (1080 * 800 px on my device).
Gdx.graphics.setWindowedMode(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
When I hit the green Maximize Icon of this Frame, it will slide to the side and take up the fullscreen. Calling it like this fullscreen won't slow down my game, and the Mac Title bar comes down when taking the mouse to the top of the screen. I have seen this behavior (workaround?) in other games.
Unfortunately the title bar in the window- mode(decorated) affects the position of my graphics. When entering fullscreen the graphics are there as they should be.
Now I thought, well ok I'll give an in-game option to enable fullscreen and call it via libgdx, and leave my window undecorated like this:
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode()); // hard fps drop
this though would drop my frame rate in an empty project to 30 FPS! This is not tolerable, and is caused due to Macs internal "optimization". See this link for more information: Sprite Kit Serious FPS Issue In Full Screen Mode on OS X
The Error is reproduce-able on MacBooks. Just download the libgdx setup, set up a new project and call Fullscreen the way I did above in the second try.
Now there are two questions.
How do I call the maximize icon click, when using an undecorated Window programmatically? I use this constructor to setup my application:
LwjglApplication(ApplicationListener listener, LwjglApplicationConfiguration config)
Does it even involve a JFrame?
What happens when clicking the icon? Do my graphics get scaled to fit the screen? Since I want a pixel game, I should only scale in whole Numbers and for this reason no antialiasing or anything is wanted here. But when going from windowed mode to fullscreen it only gets like 45 px higher. So there must be some kind of rescaling or am I wrong?
My screen resolution is 1080*800. When I print out
System.out.println("Screen Height: "+Gdx.graphics.getHeight() + " Screen Width: "+ Gdx.graphics.getWidth() );
it will show me 1080x 755 in windowed mode (the Mac title bar is visible as well as the game-windows' titlebar). When called after setting fullscreen via the icon it prints 1080*800
After hitting the green Icon:
I would use the decorated window, but somehow the sprite gets offset ( the upper one even lost, the fps counter up little) as seen above when switching from windowed to fullscreen mode.
batch.draw(generatedTexture, 0, 0);
batch.draw(generatedTexture, 0, Gdx.graphics.getHeight()-48);
currentFrame = testAnimation.getKeyFrame(stateTime, true);
batch.draw(currentFrame, xPos, yPos, 48, 96);
The sprite is 48 px high ( not filling it completely though ). Fps counter:
font.draw(batch, (int)frameRate + " fps", 3, Gdx.graphics.getHeight() - 80);
An other hint I found regarding the fps drops when calling fullscreen via the libgdx method is to use this:
-Dsun.java2d.d3d=false
but I never called any parameters upon application start up. I use Android Studio. Is there a way to insert this like a start up command in my project, to try it out?
Source:
Why does my Java application run so slowly in full-screen mode? (and fine when windowed)