From 1326ae9a5d9c33757acdb95de0fc5cc3ff989ddc Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Fri, 27 Feb 2015 03:58:40 -0400 Subject: [PATCH] Added love.graphics.clearStencil, which only clears the stencil buffer. --HG-- branch : minor --- src/modules/graphics/opengl/Graphics.cpp | 5 +++++ src/modules/graphics/opengl/Graphics.h | 5 +++++ src/modules/graphics/opengl/wrap_Graphics.cpp | 7 +++++++ src/modules/graphics/opengl/wrap_Graphics.h | 1 + 4 files changed, 18 insertions(+) diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 64288e11c..a03ac5005 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/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. diff --git a/src/modules/graphics/opengl/Graphics.h b/src/modules/graphics/opengl/Graphics.h index cd2b45abe..e93e2b159 100644 --- a/src/modules/graphics/opengl/Graphics.h +++ b/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. **/ diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index b4644cd5a..eb0f341e7 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/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 }, diff --git a/src/modules/graphics/opengl/wrap_Graphics.h b/src/modules/graphics/opengl/wrap_Graphics.h index 5270cdb89..6e5bf434f 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.h +++ b/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);