Page 1 of 2

Simple Screen Scaler

Posted: Sat May 10, 2014 6:21 pm
by Cluke009
I have been wanting an easy way to to handle screen scaling since I started using love but was never able to get any of the libraries I found to work. I finally found the time to actually work on one today and this is the result.

It handles integer and non-integer scaling, stretching, and multiple monitors.

Further documentation is in the display.lua

The only bug I know of is trying to set the screen to supported modes of a different aspect ratio. This may be a linux issue though. If I set my 16:10 monior to a 4:3 resolution its seems to scale fine.

Added loveframes to control all the scaling options.
Screenshot20140512101517.png
Screenshot20140512101517.png (130.69 KiB) Viewed 7236 times

Re: Simple Screen Scaler

Posted: Sat May 10, 2014 8:08 pm
by markgo
Sounds cool, but the demo doesn't show much.

Re: Simple Screen Scaler

Posted: Mon May 12, 2014 2:31 pm
by Cluke009
Updated the love file with something that others might find more useful for testing purposes. You can change all the display options through loveframes now.

I also found another bug where if your are in fullscreen and go from stretch to scale with fsaa=0 there are artifacts from the stretched image. With fsaa=0 the display doesnt seem to do a complete refresh after the changes are applied. Anybody know what causes this?

Re: Simple Screen Scaler

Posted: Mon May 12, 2014 6:58 pm
by dusoft
Demo does not seem to be doing anything? It just displays one image and that's it.

Re: Simple Screen Scaler

Posted: Tue May 13, 2014 8:39 am
by SiENcE
dusoft wrote:Demo does not seem to be doing anything? It just displays one image and that's it.
1. When you switch too fullscreen, the image is centered.
2. When you switch too fullscreen and your screen is twice as the gamescreen, the gamescreen is also scaled twice.
3. When you move the window to another screen and switch to fullscreen, it recognices this and shows the fullscreen on this monitor instead of your primary.

@Cluke009
Well done i would say (btw. the love file is not updated.)

I wrote a blogpost about this some time ago and I also implemented it by myself.
http://crankgaming.blogspot.de/2013/01/ ... aling.html

An alternative is also TLfres from Theal.

You should also add the mouse handling to it or at least a tip how to handle mouse when scaled to pick the right position.

Re: Simple Screen Scaler

Posted: Wed May 14, 2014 7:19 pm
by dusoft
TLFres does not work with Love2d 0.9.x, it needs to be updated to reflect changes in the window functions.

I have actually created such scaling for my game based on the notion that once ported to Android, the hardcoded resolution and the sizes of objects would just make mess.

Does this library support everything drawn via love.graphics.xxx or just the images?

Re: Simple Screen Scaler

Posted: Thu May 15, 2014 10:53 am
by SiENcE
Everything between 'set' und 'unset' i would say.

Code: Select all

    display.set()
    love.graphics.draw(bg)
    display.unset()

Re: Simple Screen Scaler

Posted: Fri May 16, 2014 6:09 am
by dusoft
Cool, I will try it and report if anything spotted.

Re: Simple Screen Scaler

Posted: Fri May 16, 2014 1:15 pm
by Cluke009
SiENcE wrote:@Cluke009
Well done i would say (btw. the love file is not updated.)

I wrote a blogpost about this some time ago and I also implemented it by myself.
http://crankgaming.blogspot.de/2013/01/ ... aling.html

An alternative is also TLfres from Theal.

You should also add the mouse handling to it or at least a tip how to handle mouse when scaled to pick the right position.
I actually read your article a while back and used it to help me decide on a good resolution for my game, it was very informative.

Love file should be updated now, not sure what happened before. TLfres was actually the first thing I looked at and I couldnt get it to work even after updating the function calls.

Had not considered mouse integration since my game only uses keyboard and joystick. I will look into it. This is still a work in progress so if anyone finds any wierd scenerios where things don't work as expected feel free to post it and I will do my best to get things working.

Re: Simple Screen Scaler

Posted: Fri May 16, 2014 2:03 pm
by SiENcE
Thanks for taking my post as inspiration :).

Yes, TLfres does not work for all possibilities. I also had to modify it to fit my needs.

What about putting it to github, choose a license (zlib?) and do a nice readme :-) ? I would like to integate it into my love2d game_template.