love.graphics.setStencil not applying over canvases?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

love.graphics.setStencil not applying over canvases?

Post by davisdude »

It came to my attention that, when paired with STI, Brady, my camera library, drew certain portions that should not have been drawn. When I use love.graphics.setScissor, it worked, though.

It works regularly when I comment out the lines from STI pertaining to drawing to a canvas, but not with the canvas.
Is this the intended result? Am I missing something?

(.love's are over on this thread if you're interested)
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
arampl
Party member
Posts: 248
Joined: Mon Oct 20, 2014 3:26 pm

Re: love.graphics.setStencil not applying over canvases?

Post by arampl »

What .love you are referring to: MV Platformer or BWE?
In both cases setShape function is never called.
Tried MV Platformer with LÖVE 0.10.0 (adapted several functions including stencil related) and it works (all is clipped to rectangular region in the top left corner).
If this is not what is needed then how result should look like? Or is this wrong .love files?
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: love.graphics.setStencil not applying over canvases?

Post by davisdude »

Can confirm with 0.10.0 (and proper porting) it works as expected. Does NOT work with 0.9.2.

You can use both:
MV Platformer is demonstrating the problem.
BWE comments out lines in STI that set canvases, and it works as expected.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
arampl
Party member
Posts: 248
Joined: Mon Oct 20, 2014 3:26 pm

Re: love.graphics.setStencil not applying over canvases?

Post by arampl »

It seems that setting / unsetting canvases cancels any defined stencils in 0.9.2:

Code: Select all

local lg = love.graphics
local canvas

function love.load()
	canvas = lg.newCanvas(800, 600)
end

function love.draw()
	lg.setStencil(function() lg.rectangle("fill", 100, 100, 200, 200) end)

	lg.setCanvas()

	lg.setColor(0, 100, 0)
	lg.circle("fill", 150, 150, 100)
end
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: love.graphics.setStencil not applying over canvases?

Post by davisdude »

Yeah, that's what I was noticing. Is this intended?
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
arampl
Party member
Posts: 248
Joined: Mon Oct 20, 2014 3:26 pm

Re: love.graphics.setStencil not applying over canvases?

Post by arampl »

Oh, I've thought question was about problems inside .love.
User avatar
slime
Solid Snayke
Posts: 3144
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: love.graphics.setStencil not applying over canvases?

Post by slime »

Stencils are effectively per-Canvas in all versions of LÖVE. The new stencil APIs in 0.10.0 make it a bit more obvious/explicit.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest