Scaling for 16:9 resolutions

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Posts: 41
Joined: Sat Aug 13, 2016 4:40 am

Scaling for 16:9 resolutions

Post by knuxyl » Wed Mar 11, 2020 9:02 am

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.

Posts: 20
Joined: Fri Jul 13, 2018 7:35 pm

Re: Scaling for 16:9 resolutions

Post by Astorek86 » Wed Mar 11, 2020 10:25 am

There are some Libs out there which provides exactly what you want. Two very good Libs are

User avatar
Party member
Posts: 2995
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary

Re: Scaling for 16:9 resolutions

Post by zorg » Wed Mar 11, 2020 8:27 pm

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
Me and my stuff :3True 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.

Post Reply

Who is online

Users browsing this forum: slime and 41 guests