Page 1 of 1

Graphics scaling

Posted: Sun Jun 15, 2014 5:21 pm
by Daniel_Cortez
Hi guys,

I'm trying to display 320x240 graphics in 1280x960 window using the love.graphics.scale() function:

Code: Select all

local SCREEN_EMULATED_WIDTH, SCREEN_EMULATED_HEIGHT = 320, 240
local SCREEN_WIDTH, SCREEN_HEIGHT = love.graphics.getDimensions()
local SCREEN_SCALE_X, SCREEN_SCALE_Y = SCREEN_WIDTH/SCREEN_EMULATED_WIDTH, SCREEN_HEIGHT/SCREEN_EMULATED_HEIGHT

function love.draw()
	love.graphics.push()
	love.graphics.scale(SCREEN_SCALE_X, SCREEN_SCALE_Y)
	frame.draw()
	love.graphics.pop()
end
For example, I'm using this image:
Image
And it's supposed to be displayed like this:
Image
But instead of that it's becoming smoothened:
Image

Is there any other convenient way in LÖVE to scale graphics without smoothing it?

Re: Graphics scaling

Posted: Sun Jun 15, 2014 5:39 pm
by slime
You can use [wiki](Image):setFilter[/wiki] with "nearest" for the magnification filter argument. If you ever upscale a Canvas or printed text, you can do the same thing via [wiki]Canvas:setFilter[/wiki] and [wiki]Font:setFilter[/wiki] (or just use [wiki]love.graphics.setDefaultFilter[/wiki] before creating any Images/Canvases/etc.)