Graphics scaling

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Daniel_Cortez
Prole
Posts: 11
Joined: Sun Apr 06, 2014 4:43 pm
Location: Novokuznetsk, Russia

Graphics scaling

Post 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?
↑↑↓↓↑↑↑↑
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Graphics scaling

Post 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.)
Post Reply

Who is online

Users browsing this forum: No registered users and 83 guests