Re scaling and Resolutions
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re scaling and Resolutions
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
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.
- 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
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.
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.
Last edited by ivan on Sat Dec 11, 2021 8:26 am, edited 2 times in total.
Re: Re scaling and Resolutions
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
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
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Re scaling and Resolutions
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.
Me and my stuff True 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.
Re: Re scaling and Resolutions
Forgot about this post, thanks for all the great replies! I am using this and it works perfectly!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
Who is online
Users browsing this forum: Amazon [Bot], Bing [Bot] and 2 guests