FullScreen viewport

I have a question. I want to do full screen but say my computer has resolution of 3840x2160. but I want the game in 1840x1940 resolution. Which is smaller. I can set the cam.resize() paramters and that changes the viewport to that size.

But the viewport is on the far left and not center. I want to make it center, but I can’t figure out how to do this. I’ve tried many different calls but nothing works.

Has anyone done this???

It doesn’t display the same as a window screen with res of 1840x1940.

Here is the window version of the game

I set the settings settings.setResolution(WIDTH, HEIGHT); to the 1840x1940 and this is what I get.

The viewport is fine, but the GUI is so wrong. I can’t take a screen shot of the game because what I get is not what you see.
Below is the screen shot but that is not what you see at all. The viewport is drawing correctly but the GUI is displayed as the screen resolution is 3840x2160 not 1840x1940.

That appears to not change the resolution but more like scaling viewport, but doesn’t affect scaling on GUI.

Does anyone know how to do this, correctly.

Check the available fullscreen resolutions for your monitor with LWJGL and use one of them to configure your app settings.

1 Like

Confirmed, if I do a guiScore .setLocalTranslation(0, 1940, 0);

This is the blue bar at the top of the screen, it puts it only about 3/4 up from the bottom of the screen.
The blue bar is 300 pixels high

I have to change position to guiScore.setLocalTranslation(0,2560 - 300, 0) then the blue bar is at the top of the screen.

That resolution is bigger than the window resolution.

My max resolution is 3840x2160.

I solved it but what I did was completely different.

When you go into full screen the viewport ends up wider and the player ends up seeing more of the world than the developer wants. Setting the screen resolution doesn’t work either because the gui ends up not drawing correctly.

So what I ended up doing is seeing what resolution the game sent. Then checked it against the resolution I want, then I scale the gui to fit the height, and then took the width and adjusted position to center it in the screen.

Next I took the scaling and converted it to 0 - 1 to match viewport. then figured out where in between 0 - 1 the position should be by calling “setViewPort(x,x,x,x)” with the ratios that would end up with the resolution that I wanted. so when the glviewPort call takes place, it has the new x,y location but the width and height match what I want the game to reflect.

When I did that the game, game came out perfect, gui scaling was correcting and the viewPort viewing was correct, no more than the window version with the resolution that I want.

Thanks.