Browse Source

Added love.graphics.clearStencil, which only clears the stencil buffer.

--HG--
branch : minor
Alex Szpakowski 10 years ago
parent
commit
1326ae9a5d

+ 5 - 0
src/modules/graphics/opengl/Graphics.cpp

@@ -575,6 +575,11 @@ void Graphics::getStencilTest(bool &enable, bool &invert)
 	invert = state.stencilInvert;
 }
 
+void Graphics::clearStencil()
+{
+	glClear(GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+}
+
 Image *Graphics::newImage(love::image::ImageData *data, const Image::Flags &flags)
 {
 	// Create the image.

+ 5 - 0
src/modules/graphics/opengl/Graphics.h

@@ -138,6 +138,11 @@ public:
 	void setStencilTest(bool enable, bool invert);
 	void getStencilTest(bool &enable, bool &invert);
 
+	/**
+	 * Clear the stencil buffer in the active Canvas(es.)
+	 **/
+	void clearStencil();
+
 	/**
 	 * Creates an Image object with padding and/or optimization.
 	 **/

+ 7 - 0
src/modules/graphics/opengl/wrap_Graphics.cpp

@@ -166,6 +166,12 @@ 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;
@@ -1531,6 +1537,7 @@ static const luaL_Reg functions[] =
 	{ "stencil", w_stencil },
 	{ "setStencilTest", w_setStencilTest },
 	{ "getStencilTest", w_getStencilTest },
+	{ "clearStencil", w_clearStencil },
 
 	{ "point", w_point },
 	{ "line", w_line },

+ 1 - 0
src/modules/graphics/opengl/wrap_Graphics.h

@@ -53,6 +53,7 @@ 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);