- Home /
how to ensure that a fixed aspect-ration game always fits inside a dynamically scaling window
I am making a game with a fixed, 1:1 aspect ratio, and up until now I have been forcing it to run in full screen and at a fixed resolution (180*180), in order to preserve the stability of certain shaders which rely on those resolution values. Today I made the switch to rendering my whole game to a rendertexture, which I then render to the screen with a dedicated orthogonal camera, that way the game can be displayed at any resolution and in a window of any size, while still retaining shader integrity. However, I encountered a small problem while messing around with the window size: when the window is very short but very wide (landscape ratio) the game shrinks to fit and has black borders on the sides, but when the window is very tall and very thin (portrait ratio) the game renders at the full height of the window and cuts off the sides that are too wide to fit. Like so: and I'm sure it must be just a toggle somewhere or something like that, but it's a hard question to search for so I figured it would be faster just to ask. If it turns out there's no neat solution then oh well it's not that big a deal, given that it works fine for landscape orientation screens, which is what I'm looking to build for anyway.
Your answer
Follow this Question
Related Questions
Resolution scaling not working correctly. 1 Answer
Resolution, camera size and 3D game objects 0 Answers
How to prevent screen size from showing more space? 0 Answers
Scaling textures 2 Answers