Hey there. I’m designing an operating system/desktop UI in MonoGame. The user interface is in 2D though I plan to do 3D rendering for certain UI effects like wobbly windows.
The issue right now is that I design the game on a 1080p 16:9 display and on that display configuration, everything fits perfectly. However, on lower resolutions and aspect ratios, windows, buttons and other UI elements are physically bigger and take up more space leading to less items fitting on screen.
Higher resolutions and aspect ratios lead to more screen real estate but also smaller UI elements and text. In 4K, the user interface is completely unusable because you cannot read anything.
So there are several things I need to tackle.
- I need to make sure that UI elements scale and translate based on the screen resolution and aspect ratio, so that everything fits in the right place, nothing gets cut off, and there’s room to draw larger text on higher resolutions.
- If I have three font sizes - small, medium and large, I want to know which one will fit best with the current GUI scale.
- I want to make sure my textures don’t get blurry and my text doesn’t get pixelated, garbled, blurry, etc.
- I want to keep
SpriteBatch
support if possible. - I’d like to keep units of measurement in pixels before the transformation is done - even if they map to a virtual screen. If I draw a rectangle at (64, 64) with the size (85x20), I want it to be rendered at 64 virtual pixels from the top left of the screen, and with a size of 85x20 virtual pixels. My virtual screen height would be 1080 pixels, and virtual screen width would be the real screen’s aspect ratio (expressed as a float) multiplied by the virtual screen height. This accounts for stuff like NVidia Surround where I actually do want more horizontal screen real estate but I want everything to be the same size as a regular non-Surround setup.
My question is, how can I do this with matrices in MonoGame at a renderer level so that the entire engine is affected and the most porting I have to do is to make sure the coordinates and sizes of all my UI elements and other objects are changed to make better use of the new renderer?
I’ve been stumped on this for months. Any help would be greatly appreciated. My game’s not going into alpha until I figure this stuff out.