diff --git a/src/modules/graphics/wrap_Graphics.lua b/src/modules/graphics/wrap_Graphics.lua index 7815edebf..6448f048f 100644 --- a/src/modules/graphics/wrap_Graphics.lua +++ b/src/modules/graphics/wrap_Graphics.lua @@ -61,15 +61,16 @@ function graphics.stencil(func, action, value, keepvalues) 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() + + graphics.setStencilMode(action, "always", value) graphics.setColorMask(false) local success, err = pcall(func) + graphics.setStencilMode(action2, mode2, value2, readmask2, writemask2) graphics.setColorMask(mr, mg, mb, ma) - graphics.setStencilMode() if not success then error(err, 2)