Browse Source

Merge pull request #1999 from Raltyro/patch-1

Fix deprecated love.graphics.stencil function resetting stencilMode
Sasha Szpakowski 1 year ago
parent
commit
8423b82dba
1 changed files with 4 additions and 3 deletions
  1. 4 3
      src/modules/graphics/wrap_Graphics.lua

+ 4 - 3
src/modules/graphics/wrap_Graphics.lua

@@ -61,15 +61,16 @@ function graphics.stencil(func, action, value, keepvalues)
 
 
 	if value == nil then value = 1 end
 	if value == nil then value = 1 end
 
 
-	graphics.setStencilMode(action, "always", value)
-
+	local action2, mode2, value2, readmask2, writemask2 = graphics.getStencilMode()
 	local mr, mg, mb, ma = graphics.getColorMask()
 	local mr, mg, mb, ma = graphics.getColorMask()
+
+	graphics.setStencilMode(action, "always", value)
 	graphics.setColorMask(false)
 	graphics.setColorMask(false)
 
 
 	local success, err = pcall(func)
 	local success, err = pcall(func)
 
 
+	graphics.setStencilMode(action2, mode2, value2, readmask2, writemask2)
 	graphics.setColorMask(mr, mg, mb, ma)
 	graphics.setColorMask(mr, mg, mb, ma)
-	graphics.setStencilMode()
 
 
 	if not success then
 	if not success then
 		error(err, 2)
 		error(err, 2)