Page 1 of 1

Re scaling and Resolutions

Posted: Sun Jan 27, 2019 9:27 pm
by xDVexan
So, I have been looking for a few hours now trying to find how to scale things properly. I can't find anything helpful and most things don't work. Is there a lib for rescaling? I know LOVE has the love.graphics.scale() func. but It doesn't seem to work well.

Re: Re scaling and Resolutions

Posted: Sun Jan 27, 2019 11:51 pm
by pgimeno
That's not very specific. love.graphics.scale() does what it's supposed to do, but I'm not sure what you're expecting to get.

- If you expect pixelation instead of interpolation, you can set love.graphics.setDefaultFilter("nearest", "nearest").
- If you are trying to reduce images to under 50% of their size, you'll need to activate mipmaps for them to look good, and the first parameter of setDefaultFilter should be kept at "linear".
- If you're rendering text and you want it to not look pixelated or blurred, you need to create fonts appropriate to the resolution you choose.

Re: Re scaling and Resolutions

Posted: Mon Jan 28, 2019 6:36 am
by ivan
Sure, the scale function works perfectly you just have to study the documentation to figure out how it works.
Now there are more difficult problems involved with scaling, especially if want to avoid stretching, etc.
Another solution is to use a scene graph:
https://github.com/2dengine/love.scene
With the scene graph, you are basically rendering everything to a "viewport" which can be scaled and resized automatically.

Re: Re scaling and Resolutions

Posted: Mon Jan 28, 2019 3:51 pm
by crystal
simply do

myW, myH = 500, 900
W, H = love.graphics.getDimensions()
scaleW, scaleH = W/myW, H/myH
...

love.draw()
love.graphics.push()
love.graphics.scale(scaleW,scaleW)
--draw game stuff
love.graphics.pop()
end

if you want to avoid stretching you must use same scaling factor for width and height

Re: Re scaling and Resolutions

Posted: Mon Jan 28, 2019 4:29 pm
by zorg
crystal wrote: Mon Jan 28, 2019 3:51 pm myW, myH = 500, 900
W, H = love.graphics.getDimensions()
scaleW, scaleH = W/myW, H/myH
...

love.draw()
love.graphics.push()
love.graphics.scale(scaleW,scaleW)
--draw game stuff
love.graphics.pop()
end
You are assuming that the height is larger than the width; that's usually only the case with phones, not desktops; a better method would be to have one scaling variable that uses the minimum of W/myW and H/myH (if you want dynamic letter/pillar-boxing; use maximum if you want to cut off the excess on the larger axis), because that's a better solution.

Re: Re scaling and Resolutions

Posted: Sun Feb 03, 2019 5:42 pm
by xDVexan
crystal wrote: Mon Jan 28, 2019 3:51 pm simply do

myW, myH = 500, 900
W, H = love.graphics.getDimensions()
scaleW, scaleH = W/myW, H/myH
...

love.draw()
love.graphics.push()
love.graphics.scale(scaleW,scaleW)
--draw game stuff
love.graphics.pop()
end

if you want to avoid stretching you must use same scaling factor for width and height
Forgot about this post, thanks for all the great replies! I am using this and it works perfectly!