[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 »

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 181 times
Last edited by milkbomb11 on Tue Jan 29, 2019 2:22 am, edited 1 time in total.
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

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

Post by ivan »

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 »

You could also switch lines in love.load
User avatar
pgimeno
Party member
Posts: 3549
Joined: Sun Oct 18, 2015 2:58 pm

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

Post by pgimeno »

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 »

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 »

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: Amazon [Bot], Google [Bot] and 85 guests