[Snippet] Screen Scaler Helper

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
markgo
Party member
Posts: 190
Joined: Sat Jan 05, 2013 12:21 am
Location: USA

[Snippet] Screen Scaler Helper

Post by markgo »

Simple module to maintain aspect ratio at any resolution. You need to specify your reference resolution and the screen resolution. Your reference resolution will be scaled to the screen resolution while maintaining it's aspect ratio. It's important for your code to be resolution independent by pointing to the reference resolution at all times. Try typing in some different screen resolutions! Letterboxing is automatic by scissoring.

EDIT: Fullscreen not so friendly with weird resolutions. Don't go fullscreen and set a non supported resolution or else it won't scale correctly!
EDIT2: Clamped mouse position
EDIT3: Added other modes of scaling
EDIT4: Added nearest mode for integer based zooming
EDIT5: Fixed screenPosition
Attachments
res.lua
(2.01 KiB) Downloaded 646 times
res.love
(1.86 KiB) Downloaded 559 times
Last edited by markgo on Fri Aug 02, 2013 1:06 am, edited 9 times in total.
User avatar
xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am
Location: Canada

Re: [Snippet] Aspect Ratio Scaler

Post by xXxMoNkEyMaNxXx »

Neat, maybe restrict the returned mouse position to being on screen?
User avatar
Daniel Eakins
Citizen
Posts: 99
Joined: Thu Jul 18, 2013 9:14 pm
Location: France

Re: [Snippet] Screen Scaler Helper

Post by Daniel Eakins »

This script is awesome. I second xXxMoNkEyMaNxXx's question but otherwise this works perfectly!
User avatar
SiENcE
Party member
Posts: 806
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: [Snippet] Screen Scaler Helper

Post by SiENcE »

I wrote a longer Blogpost about scaling pixelperfect to fullscreen. You might want to read this.

http://crankgaming.blogspot.de/2013/01/ ... aling.html

humansarepuppies implemented this idea and code is on github.

https://github.com/humansarepuppies/eng ... en-scaling
User avatar
Daniel Eakins
Citizen
Posts: 99
Joined: Thu Jul 18, 2013 9:14 pm
Location: France

Re: [Snippet] Screen Scaler Helper

Post by Daniel Eakins »

This is definitely interesting stuff. Thanks!

---

EDIT: There seems to be an error in r.screenPosition :(
User avatar
markgo
Party member
Posts: 190
Joined: Sat Jan 05, 2013 12:21 am
Location: USA

Re: [Snippet] Screen Scaler Helper

Post by markgo »

Hi, Daniel. I should really test my stuff. See the first post for the update.
User avatar
Daniel Eakins
Citizen
Posts: 99
Joined: Thu Jul 18, 2013 9:14 pm
Location: France

Re: [Snippet] Screen Scaler Helper

Post by Daniel Eakins »

Thanks :)
User avatar
Helvecta
Party member
Posts: 167
Joined: Wed Sep 26, 2012 6:35 pm

Re: [Snippet] Screen Scaler Helper

Post by Helvecta »

I needed something like this so badly, time to tear it apart and devour its soul implement it!

Thanks for this great snippet! :3
"Bump." -CMFIend420
xCode195
Prole
Posts: 6
Joined: Fri Oct 04, 2013 8:33 pm

Re: [Snippet] Screen Scaler Helper

Post by xCode195 »

Sorry for bumping this thread :death: , but i have been using this snippet for scaling to different resolutions in 0.8.0 and it has been working wonderfully there.After I updated to 0.9.1 I have been getting very weird results with this snippet(look at screenshots below) and now I can't use my game on resolutions other than the one it was designed for(which is 1366x768).

So, I'm wondering if anyone has fixed this for 0.9 or has a better way to support different resolutions?

How it's supposed to be:
Image

How it is in 0.9.1:
Image
xCode195
Prole
Posts: 6
Joined: Fri Oct 04, 2013 8:33 pm

Re: [Snippet] Screen Scaler Helper

Post by xCode195 »

xCode195 wrote:-snip-
Sorry for bumping again,but... Ideas anyone?
I think the calculations for setScissor() function are wrong but I can't fix them :(
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests