Fix Issue #278: Set default filter mode for new images.

Add the somewhat lengthy named love.graphics.getDefaultImageFilter() and
love.graphics.getDefaultImageFilter(). The verbose name should point to the
fact that changing the default filter midway through the game will not affect
the images already loaded using love.graphics.newImage().
This commit is contained in:
vrld
2011-10-07 14:44:17 +02:00
parent bee9d49515
commit 48137cd2e1
7 changed files with 64 additions and 7 deletions
@@ -568,6 +568,25 @@ namespace opengl
return 0;
}
int w_setDefaultImageFilter(lua_State * L)
{
Image::FilterMode min;
Image::FilterMode mag;
const char * minstr = luaL_checkstring(L, 1);
const char * magstr = luaL_checkstring(L, 2);
if (!Image::getConstant(minstr, min))
return luaL_error(L, "Invalid filter mode: %s", minstr);
if (!Image::getConstant(magstr, mag))
return luaL_error(L, "Invalid filter mode: %s", magstr);
Image::Filter f;
f.min = min;
f.mag = mag;
instance->setDefaultImageFilter(f);
return 0;
}
int w_getBlendMode(lua_State * L)
{
Graphics::BlendMode mode = instance->getBlendMode();
@@ -590,6 +609,18 @@ namespace opengl
return 1;
}
int w_getDefaultImageFilter(lua_State * L)
{
const Image::Filter& f = instance->getDefaultImageFilter();
const char * minstr;
const char * magstr;
Image::getConstant(f.min, minstr);
Image::getConstant(f.mag, magstr);
lua_pushstring(L, minstr);
lua_pushstring(L, magstr);
return 2;
}
int w_setLineWidth(lua_State * L)
{
float width = (float)luaL_checknumber(L, 1);
@@ -1159,8 +1190,10 @@ namespace opengl
{ "setBlendMode", w_setBlendMode },
{ "setColorMode", w_setColorMode },
{ "setDefaultImageFilter", w_setDefaultImageFilter },
{ "getBlendMode", w_getBlendMode },
{ "getColorMode", w_getColorMode },
{ "getDefaultImageFilter", w_getDefaultImageFilter },
{ "setLineWidth", w_setLineWidth },
{ "setLineStyle", w_setLineStyle },
{ "setLine", w_setLine },