I'm making a game that I want to always render in 16:9. I will have the window settings be controllable in the game so no maximize/resize buttons on the window itself. I want the game to fit on all screens, but have black borders on different aspect ratios. I also want to be able to scale the game properly. I was going to use percentages of the screen but there's too many fractions involved which can cause graphical problems in other resolutions.
Anways, I'm using a canvas. I need it to always be 16:9 and be able to scale. I've been working on and off on this for years and I used to just use the scale argument but it makes the code clunky but it's looking like thats the best option. I have no idea how to go about the 16:9 resolutions though. Any ideas? I will be porting this game to all platforms, Android/IOS/Mac/Windows and I'm using Linux.
Scaling for 16:9 resolutions
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Scaling for 16:9 resolutions
There are some Libs out there which provides exactly what you want. Two very good Libs are
- "push"-Library (I recommend this)
- "Aspect Ratio"-Library
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Scaling for 16:9 resolutions
Or if you want the explanation bit, there's only ever 3 cases you need to care about with the expectation of you always wanting your canvas to be 16:9 aspect ratio with fullscreen:
- the screen is already 16:9 -> nothing to do
- the screen is vertically larger -> you need to letterbox the top and bottom, meaning you'll offset your rendering vertically by (screenheight -closest_smaller_16:9_height) / 2
- the screen is horizontally larger -> you need to pillarbox the sides, meaning you'll offset your rendering horizontally by (screenwidth - closest_smaller_16:9_width) / 2
- the screen is already 16:9 -> nothing to do
- the screen is vertically larger -> you need to letterbox the top and bottom, meaning you'll offset your rendering vertically by (screenheight -closest_smaller_16:9_height) / 2
- the screen is horizontally larger -> you need to pillarbox the sides, meaning you'll offset your rendering horizontally by (screenwidth - closest_smaller_16:9_width) / 2
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Who is online
Users browsing this forum: Bing [Bot], Semrush [Bot] and 12 guests