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

View file

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