Add masking (see issue #211). Only "hard" masks are supported, no

semitransparent ones.

--HG--
branch : minor
This commit is contained in:
vrld
2011-04-26 22:10:34 +02:00
parent 1b8b144bc8
commit 939041886c
4 changed files with 71 additions and 0 deletions
@@ -144,6 +144,33 @@ namespace opengl
return instance->getScissor(L);
}
int w_defineMask(lua_State * L)
{
// just return the function
if (!lua_isfunction(L, 1))
return luaL_typerror(L, 1, "function");
lua_settop(L, 1);
return 1;
}
int w_setMask(lua_State * L)
{
// no argument -> clear mask
if (lua_isnoneornil(L, 1)) {
instance->discardMask();
return 0;
}
if (!lua_isfunction(L, 1))
return luaL_typerror(L, 1, "mask");
instance->defineMask();
lua_call(L, lua_gettop(L) - 1, 0); // call mask(...)
instance->useMask();
return 0;
}
int w_newImage(lua_State * L)
{
// Convert to File, if necessary.
@@ -1020,6 +1047,9 @@ namespace opengl
{ "setScissor", w_setScissor },
{ "getScissor", w_getScissor },
{ "defineMask", w_defineMask },
{ "setMask", w_setMask },
{ "point", w_point },
{ "line", w_line },
{ "triangle", w_triangle },