Browse Source

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'.)

Alex Szpakowski 10 years ago
parent
commit
52b2701cf0

+ 1 - 1
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.

+ 6 - 9
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 },

+ 0 - 1
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);