mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +02:00
Rename 'defineMask' to 'newMask'. Add inverted mask (issue #226).
This commit is contained in:
@@ -437,9 +437,9 @@ namespace opengl
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
||||
}
|
||||
|
||||
void Graphics::useMask()
|
||||
void Graphics::useMask(bool invert)
|
||||
{
|
||||
glStencilFunc(GL_EQUAL, 1, 1);
|
||||
glStencilFunc(GL_EQUAL, (int)(!invert), 1); // invert ? 0 : 1
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
}
|
||||
|
||||
@@ -242,8 +242,10 @@ namespace opengl
|
||||
/**
|
||||
* Set stencil function to mask the following drawing calls using
|
||||
* the current stencil buffer
|
||||
* @param invert Invert the mask, i.e. draw everywhere expect where
|
||||
* the mask is defined.
|
||||
*/
|
||||
void useMask();
|
||||
void useMask(bool invert = false);
|
||||
|
||||
/**
|
||||
* Disables the stencil buffer
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace opengl
|
||||
return instance->getScissor(L);
|
||||
}
|
||||
|
||||
int w_defineMask(lua_State * L)
|
||||
int w_newMask(lua_State * L)
|
||||
{
|
||||
// just return the function
|
||||
if (!lua_isfunction(L, 1))
|
||||
@@ -153,7 +153,7 @@ namespace opengl
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_setMask(lua_State * L)
|
||||
static int setMask(lua_State * L, bool invert)
|
||||
{
|
||||
// no argument -> clear mask
|
||||
if (lua_isnoneornil(L, 1)) {
|
||||
@@ -166,11 +166,21 @@ namespace opengl
|
||||
|
||||
instance->defineMask();
|
||||
lua_call(L, lua_gettop(L) - 1, 0); // call mask(...)
|
||||
instance->useMask();
|
||||
instance->useMask(invert);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_setMask(lua_State * L)
|
||||
{
|
||||
return setMask(L, false);
|
||||
}
|
||||
|
||||
int w_setInvertedMask(lua_State * L)
|
||||
{
|
||||
return setMask(L, true);
|
||||
}
|
||||
|
||||
int w_newImage(lua_State * L)
|
||||
{
|
||||
// Convert to File, if necessary.
|
||||
@@ -1047,8 +1057,9 @@ namespace opengl
|
||||
{ "setScissor", w_setScissor },
|
||||
{ "getScissor", w_getScissor },
|
||||
|
||||
{ "defineMask", w_defineMask },
|
||||
{ "newMask", w_newMask },
|
||||
{ "setMask", w_setMask },
|
||||
{ "setInvertedMask", w_setInvertedMask },
|
||||
|
||||
{ "point", w_point },
|
||||
{ "line", w_line },
|
||||
|
||||
Reference in New Issue
Block a user