Changed the optional 'multiply alpha' boolean argument in love.graphics.setBlendMode to be an enum with constants 'alphamultiply' and 'premultiplied'.

The default value for the second argument of setBlendMode is 'alphamultiply'.
This commit is contained in:
Alex Szpakowski
2015-12-16 14:53:16 -04:00
parent 39127cd1b2
commit 48345bd58c
5 changed files with 61 additions and 21 deletions
+15 -6
View File
@@ -1042,25 +1042,34 @@ int w_setBlendMode(lua_State *L)
if (!Graphics::getConstant(str, mode))
return luaL_error(L, "Invalid blend mode: %s", str);
bool multiplyalpha = luax_optboolean(L, 2, true);
Graphics::BlendAlpha alphamode = Graphics::BLENDALPHA_MULTIPLY;
if (!lua_isnoneornil(L, 2))
{
const char *alphastr = luaL_checkstring(L, 2);
if (!Graphics::getConstant(alphastr, alphamode))
return luaL_error(L, "Invalid blend alpha mode: %s", alphastr);
}
luax_catchexcept(L, [&](){ instance()->setBlendMode(mode, multiplyalpha); });
luax_catchexcept(L, [&](){ instance()->setBlendMode(mode, alphamode); });
return 0;
}
int w_getBlendMode(lua_State *L)
{
const char *str;
Graphics::BlendMode mode;
bool multiplyalpha = false;
const char *alphastr;
luax_catchexcept(L, [&](){ mode = instance()->getBlendMode(multiplyalpha); });
Graphics::BlendAlpha alphamode;
Graphics::BlendMode mode = instance()->getBlendMode(alphamode);
if (!Graphics::getConstant(mode, str))
return luaL_error(L, "Unknown blend mode");
if (!Graphics::getConstant(alphamode, alphastr))
return luaL_error(L, "Unknown blend alpha mode");
lua_pushstring(L, str);
lua_pushboolean(L, multiplyalpha);
lua_pushstring(L, alphastr);
return 2;
}