[SOLVED]setDefaultFilter("nearest", "nearest") not working

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
milkbomb11
Prole
Posts: 21
Joined: Mon Jan 07, 2019 12:38 pm

[SOLVED]setDefaultFilter("nearest", "nearest") not working

Post by milkbomb11 » Mon Jan 28, 2019 3:04 pm

In love.load, I typed in love.graphics.setDefaultFilter("nearest", "nearest") to make the images even when scaled up, look good and not blurry. But setDefaultFilter("nearest", "nearest") isn't working: the image is still blurry :(

The code :

Code: Select all

function love.load()
  playerImg = love.graphics.newImage("Images/GameJamPlayer.png") --player image which is 32x32
  love.graphics.setDefaultFilter("nearest", "nearest") -- the problem code that doesn't seem to be working 
end

function love.draw()
  love.graphics.draw(playerImg, 0, 0, 0, 5, 5) --drawing the player image at (0, 0) with the size boosted up 5 times
end
The .love file :
Test.love
(762 Bytes) Downloaded 47 times
Last edited by milkbomb11 on Tue Jan 29, 2019 2:22 am, edited 1 time in total.

User avatar
ivan
Party member
Posts: 1560
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: setDefaultFilter("nearest", "nearest") not working

Post by ivan » Mon Jan 28, 2019 3:18 pm

I think you need to set this per image as it will not work retroactively:
playerImg:setFilter("nearest", "nearest")

User avatar
arampl
Party member
Posts: 248
Joined: Mon Oct 20, 2014 3:26 pm

Re: setDefaultFilter("nearest", "nearest") not working

Post by arampl » Mon Jan 28, 2019 3:19 pm

You could also switch lines in love.load

User avatar
pgimeno
Party member
Posts: 2168
Joined: Sun Oct 18, 2015 2:58 pm

Re: setDefaultFilter("nearest", "nearest") not working

Post by pgimeno » Mon Jan 28, 2019 6:57 pm

Yeah, the filter is a per-image setting. You use setDefaultFilter to set the default that will apply to all images created after you call it.

milkbomb11
Prole
Posts: 21
Joined: Mon Jan 07, 2019 12:38 pm

Re: setDefaultFilter("nearest", "nearest") not working

Post by milkbomb11 » Tue Jan 29, 2019 2:20 am

ivan wrote:
Mon Jan 28, 2019 3:18 pm
I think you need to set this per image as it will not work retroactively:
playerImg:setFilter("nearest", "nearest")
setting the individual image's filter worked! :D
Thank you!

milkbomb11
Prole
Posts: 21
Joined: Mon Jan 07, 2019 12:38 pm

Re: setDefaultFilter("nearest", "nearest") not working

Post by milkbomb11 » Tue Jan 29, 2019 2:21 am

arampl wrote:
Mon Jan 28, 2019 3:19 pm
You could also switch lines in love.load
Switching the lines in love.load() worked! :D
Thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 35 guests