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.
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.
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.