Cleaned up some graphics code.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-06-10 15:09:33 -03:00
parent 9fe81ad922
commit 45de7cebb6
6 changed files with 81 additions and 76 deletions
+6 -2
View File
@@ -527,14 +527,18 @@ int w_stencil(lua_State *L)
int stencilvalue = (int) luaL_optnumber(L, 3, 1);
// Fourth argument: whether to keep the contents of the stencil buffer.
OptionalInt stencilclear;
int argtype = lua_type(L, 4);
if (argtype == LUA_TNONE || argtype == LUA_TNIL || (argtype == LUA_TBOOLEAN && luax_toboolean(L, 4) == false))
instance()->clearStencil(0);
stencilclear.set(0);
else if (argtype == LUA_TNUMBER)
instance()->clearStencil((int) luaL_checkinteger(L, 4));
stencilclear.set((int) luaL_checkinteger(L, 4));
else if (argtype != LUA_TBOOLEAN)
luaL_checktype(L, 4, LUA_TBOOLEAN);
if (stencilclear.hasValue)
instance()->clear(OptionalColorf(), stencilclear, OptionalDouble());
luax_catchexcept(L, [&](){ instance()->drawToStencilBuffer(action, stencilvalue); });
// Call stencilfunc()