The old love.graphics stencil APIs are deprecated, not removed.

This commit is contained in:
Sasha Szpakowski
2023-02-11 11:35:04 -04:00
parent 1a586f8156
commit 60a8fca45c
2 changed files with 47 additions and 4 deletions
+2 -2
View File
@@ -112,6 +112,8 @@ Released: N/A
* Deprecated love.graphics.setNewFont (use love.graphics.newFont and love.graphics.setFont instead).
* Deprecated love.graphics.newText (renamed to love.graphics.newTextBatch).
* Deprecated love.graphics.getImageFormats and love.graphics.getCanvasFormats (replaced by getTextureFormats).
* Deprecated love.graphics.stencil (replaced by love.graphics.setStencilMode).
* Deprecated love.graphics.setStencilTest and love.graphics.getStencilTest (replaced by love.graphics.setStencilMode and getStencilMode).
* Deprecated t.window.highdpi in love.conf and the highdpi flag of love.window.setMode (replaced by t.highdpi in love.conf).
* Deprecated t.accelerometerjoystick in love.conf (replaced by love.sensor module).
* Deprecated the variants of Mesh:attachAttribute and SpriteBatch:attachAttribute which accept a Mesh (replaced by variants which accept a Buffer).
@@ -119,8 +121,6 @@ Released: N/A
* Removed the variant of SpriteBatch:setColor() which turns off all previously set colors.
* Removed the no-argument variant of love.graphics.setColorMask.
* Removed love.graphics.stencil (replaced by love.graphics.setStencilMode).
* Removed love.graphics.setStencilTest and getStencilTest (replaced by love.graphics.setStencilMode and getStencilMode).
* Fixed BezierCurve:render adding collinear points in some situations.
* Fixed line rendering when the line has duplicate points.
+45 -2
View File
@@ -24,8 +24,10 @@ misrepresented as being the original software.
local table_concat = table.concat
local ipairs = ipairs
local pcall = pcall
local graphics = love.graphics
function love.graphics.newVideo(file, settings)
function graphics.newVideo(file, settings)
settings = settings == nil and {} or settings
if type(settings) ~= "table" then error("bad argument #2 to newVideo (expected table)", 2) end
@@ -50,7 +52,48 @@ function love.graphics.newVideo(file, settings)
return video
end
function love.graphics._transformGLSLErrorMessages(message)
function graphics.stencil(func, action, value, keepvalues)
love.markDeprecated(2, "love.graphics.stencil", "function", "replaced", "love.graphics.setStencilMode")
if not keepvalues then
graphics.clear(false, true, false)
end
if value == nil then value = 1 end
graphics.setStencilMode(action, "always", value)
local mr, mg, mb, ma = graphics.getColorMask()
graphics.setColorMask(false)
local success, err = pcall(func)
graphics.setColorMask(mr, mg, mb, ma)
graphics.setStencilMode()
if not success then
error(err, 2)
end
end
function graphics.setStencilTest(mode, value)
love.markDeprecated(2, "love.graphics.setStencilTest", "function", "replaced", "love.graphics.setStencilMode")
if mode ~= nil then
graphics.setStencilMode("keep", mode, value)
else
graphics.setStencilMode()
end
end
function graphics.getStencilTest()
love.markDeprecated(2, "love.graphics.getStencilTest", "function", "replaced", "love.graphics.getStencilMode")
local action, mode, value = graphics.getStencilMode()
return mode, value
end
function graphics._transformGLSLErrorMessages(message)
local shadertype = message:match("Cannot compile (%a+) shader code")
local compiling = shadertype ~= nil
if not shadertype then