Page 1 of 2

[Snippet] Screen Scaler Helper

Posted: Wed Jan 23, 2013 9:34 pm
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

Re: [Snippet] Aspect Ratio Scaler

Posted: Thu Jan 24, 2013 12:16 am
by xXxMoNkEyMaNxXx
Neat, maybe restrict the returned mouse position to being on screen?

Re: [Snippet] Screen Scaler Helper

Posted: Thu Jul 18, 2013 9:48 pm
by Daniel Eakins
This script is awesome. I second xXxMoNkEyMaNxXx's question but otherwise this works perfectly!

Re: [Snippet] Screen Scaler Helper

Posted: Fri Jul 19, 2013 12:07 pm
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

Re: [Snippet] Screen Scaler Helper

Posted: Thu Aug 01, 2013 8:57 pm
by Daniel Eakins
This is definitely interesting stuff. Thanks!

---

EDIT: There seems to be an error in r.screenPosition :(

Re: [Snippet] Screen Scaler Helper

Posted: Fri Aug 02, 2013 1:03 am
by markgo
Hi, Daniel. I should really test my stuff. See the first post for the update.

Re: [Snippet] Screen Scaler Helper

Posted: Sun Aug 04, 2013 12:40 am
by Daniel Eakins
Thanks :)

Re: [Snippet] Screen Scaler Helper

Posted: Sun Aug 04, 2013 7:07 pm
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

Re: [Snippet] Screen Scaler Helper

Posted: Sun Apr 06, 2014 2:57 pm
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

Re: [Snippet] Screen Scaler Helper

Posted: Tue Apr 08, 2014 7:53 pm
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 :(