fix stencil after some discussion in #1818 in love2d/love

This commit is contained in:
Er2 2022-07-09 15:39:12 +03:00
parent ab8638bfe5
commit c0a8f03063
2 changed files with 15 additions and 8 deletions

View file

@ -12,16 +12,20 @@ if love.getVersion() >= 12 then
end end
else else
local ffi = require 'ffi' local ffi = require 'ffi'
local liblove = ffi.os == 'Windows'
and ffi.load 'love'
or ffi.C -- thanks to slime73, Love2D developer :)
ffi.cdef [[ ffi.cdef [[
int PHYSFS_mount(const char *, const char *, int); int PHYSFS_mount(const char *, const char *, int);
int PHYSFS_unmount(const char *);]] int PHYSFS_unmount(const char *);]]
-- FIXME: Bug may appear in Linux. Recompile Love2D or use official PPA. -- FIXME: Bug may appear in Linux. Recompile Love2D or use official PPA.
function ll._mntdir(dir) function ll._mntdir(dir)
return ffi.C.PHYSFS_mount(dir, '/', 0) ~= 0 return liblove.PHYSFS_mount(dir, '/', 0) ~= 0
end end
function ll._umntdir(dir) function ll._umntdir(dir)
ffi.C.PHYSFS_unmount(dir) liblove.PHYSFS_unmount(dir)
end end
end end

View file

@ -14,13 +14,16 @@ function llHome()
end end
if love.getVersion() >= 12 then if love.getVersion() >= 12 then
local stfn function love.graphics.stencil(fn)
function love.graphics.stencil(fn) stfn = fn end love.graphics.setColorMask(false)
love.graphics.setStencilMode('replace', 'always', 1)
fn()
love.graphics.setColorMask(true)
end
function love.graphics.setStencilTest(cmp, val) function love.graphics.setStencilTest(cmp, val)
if not cmp if cmp
then love.graphics.setStencilMode() then love.graphics.setStencilMode('keep', cmp, val)
else love.graphics.setStencilMode('replace', cmp, val, 1, 1) else love.graphics.setStencilMode()
stfn()
end end
end end
end end