mirror of
https://github.com/love2d/love.git
synced 2026-08-20 12:40:20 +02:00
Added Image:getFlags.
This commit is contained in:
@@ -101,6 +101,29 @@ int w_Image_getData(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *imageFlagName(Image::FlagType flagtype)
|
||||||
|
{
|
||||||
|
const char *name = nullptr;
|
||||||
|
Image::getConstant(flagtype, name);
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
int w_Image_getFlags(lua_State *L)
|
||||||
|
{
|
||||||
|
Image *i = luax_checkimage(L, 1);
|
||||||
|
Image::Flags flags = i->getFlags();
|
||||||
|
|
||||||
|
lua_createtable(L, 0, 2);
|
||||||
|
|
||||||
|
lua_pushboolean(L, flags.mipmaps);
|
||||||
|
lua_setfield(L, -2, imageFlagName(Image::FLAG_TYPE_MIPMAPS));
|
||||||
|
|
||||||
|
lua_pushboolean(L, flags.sRGB);
|
||||||
|
lua_setfield(L, -2, imageFlagName(Image::FLAG_TYPE_SRGB));
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static const luaL_Reg functions[] =
|
static const luaL_Reg functions[] =
|
||||||
{
|
{
|
||||||
// From wrap_Texture.
|
// From wrap_Texture.
|
||||||
@@ -117,6 +140,7 @@ static const luaL_Reg functions[] =
|
|||||||
{ "isCompressed", w_Image_isCompressed },
|
{ "isCompressed", w_Image_isCompressed },
|
||||||
{ "refresh", w_Image_refresh },
|
{ "refresh", w_Image_refresh },
|
||||||
{ "getData", w_Image_getData },
|
{ "getData", w_Image_getData },
|
||||||
|
{ "getFlags", w_Image_getFlags },
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ int w_Image_getMipmapFilter(lua_State *L);
|
|||||||
int w_Image_isCompressed(lua_State *L);
|
int w_Image_isCompressed(lua_State *L);
|
||||||
int w_Image_refresh(lua_State *L);
|
int w_Image_refresh(lua_State *L);
|
||||||
int w_Image_getData(lua_State *L);
|
int w_Image_getData(lua_State *L);
|
||||||
|
int w_Image_getFlags(lua_State *L);
|
||||||
extern "C" int luaopen_image(lua_State *L);
|
extern "C" int luaopen_image(lua_State *L);
|
||||||
|
|
||||||
} // opengl
|
} // opengl
|
||||||
|
|||||||
Reference in New Issue
Block a user