From 52b2701cf09cad293d4903e379d7f16e3ee38179 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Mon, 9 Mar 2015 23:05:29 -0300 Subject: [PATCH] Removed love.graphics.clearStencil. love.graphics.stencil now clears the stencil buffer unless true is passed as an optional second argument ('keep the existing contents'.) --- changes.txt | 2 +- src/modules/graphics/opengl/wrap_Graphics.cpp | 15 ++++++--------- src/modules/graphics/opengl/wrap_Graphics.h | 1 - 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/changes.txt b/changes.txt index 899af6a42..4b06f81d8 100644 --- a/changes.txt +++ b/changes.txt @@ -16,7 +16,7 @@ Released: N/A * Added Source:getType (replaces Source:isStatic.) * Added love.graphics.getSupported (replaces love.graphics.isSupported.) * Added love.graphics.getSystemLimits (replaces love.graphics.getSystemLimit.) - * Added love.graphics.stencil, love.graphics.setStencilTest, and love.graphics.clearStencil (replaces love.graphics.setStencil.) + * Added love.graphics.stencil and love.graphics.setStencilTest (replaces love.graphics.setStencil.) * Added love.graphics.isActive. * Added color arguments to love.graphics.clear. It no longer always uses the background color value. * Added love.graphics.discard. diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index 17f0f12c6..4727e47af 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -161,10 +161,14 @@ int w_stencil(lua_State *L) { luaL_checktype(L, 1, LUA_TFUNCTION); + // Second argument: whether to keep the contents of the stencil buffer. + if (lua_toboolean(L, 2) == 0) + instance()->clearStencil(); + instance()->drawToStencilBuffer(true); - // Call stencilfunc(...) - lua_call(L, lua_gettop(L) - 1, 0); + // Call stencilfunc() + lua_call(L, 0, 0); instance()->drawToStencilBuffer(false); @@ -188,12 +192,6 @@ int w_getStencilTest(lua_State *L) return 2; } -int w_clearStencil(lua_State* /*L*/) -{ - instance()->clearStencil(); - return 0; -} - static const char *imageFlagName(Image::FlagType flagtype) { const char *name = nullptr; @@ -1560,7 +1558,6 @@ static const luaL_Reg functions[] = { "stencil", w_stencil }, { "setStencilTest", w_setStencilTest }, { "getStencilTest", w_getStencilTest }, - { "clearStencil", w_clearStencil }, { "point", w_point }, { "line", w_line }, diff --git a/src/modules/graphics/opengl/wrap_Graphics.h b/src/modules/graphics/opengl/wrap_Graphics.h index ce30adbc9..504c56a8b 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.h +++ b/src/modules/graphics/opengl/wrap_Graphics.h @@ -54,7 +54,6 @@ int w_getScissor(lua_State *L); int w_stencil(lua_State *L); int w_setStencilTest(lua_State *L); int w_getStencilTest(lua_State *L); -int w_clearStencil(lua_State *L); int w_newImage(lua_State *L); int w_newQuad(lua_State *L); int w_newFont(lua_State *L);