mirror of
https://github.com/love2d/love-android.git
synced 2026-08-19 20:20:25 +02:00
Using latest android branch of LÖVE (6d14516b05c9) that now syncs with default (woooo!)
This commit is contained in:
@@ -30,7 +30,7 @@ namespace opengl
|
||||
|
||||
Image *luax_checkimage(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Image>(L, idx, "Image", GRAPHICS_IMAGE_T);
|
||||
return luax_checktype<Image>(L, idx, GRAPHICS_IMAGE_ID);
|
||||
}
|
||||
|
||||
int w_Image_setMipmapFilter(lua_State *L)
|
||||
@@ -48,9 +48,7 @@ int w_Image_setMipmapFilter(lua_State *L)
|
||||
}
|
||||
|
||||
luax_catchexcept(L, [&](){ t->setFilter(f); });
|
||||
|
||||
float sharpness = (float) luaL_optnumber(L, 3, 0);
|
||||
t->setMipmapSharpness(sharpness);
|
||||
t->setMipmapSharpness((float) luaL_optnumber(L, 3, 0.0));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -81,7 +79,13 @@ int w_Image_isCompressed(lua_State *L)
|
||||
int w_Image_refresh(lua_State *L)
|
||||
{
|
||||
Image *i = luax_checkimage(L, 1);
|
||||
luax_catchexcept(L, [&](){ i->refresh(); });
|
||||
|
||||
int xoffset = (int) luaL_optnumber(L, 2, 0);
|
||||
int yoffset = (int) luaL_optnumber(L, 3, 0);
|
||||
int w = (int) luaL_optnumber(L, 4, i->getWidth());
|
||||
int h = (int) luaL_optnumber(L, 5, i->getHeight());
|
||||
|
||||
luax_catchexcept(L, [&](){ i->refresh(xoffset, yoffset, w, h); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -90,21 +94,32 @@ int w_Image_getData(lua_State *L)
|
||||
Image *i = luax_checkimage(L, 1);
|
||||
|
||||
if (i->isCompressed())
|
||||
{
|
||||
love::image::CompressedData *t = i->getCompressedData();
|
||||
if (t)
|
||||
luax_pushtype(L, "CompressedData", IMAGE_COMPRESSED_DATA_T, t);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
}
|
||||
luax_pushtype(L, IMAGE_COMPRESSED_IMAGE_DATA_ID, i->getCompressedData());
|
||||
else
|
||||
{
|
||||
love::image::ImageData *t = i->getImageData();
|
||||
if (t)
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, t);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
}
|
||||
luax_pushtype(L, IMAGE_IMAGE_DATA_ID, i->getImageData());
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -125,12 +140,13 @@ static const luaL_Reg functions[] =
|
||||
{ "isCompressed", w_Image_isCompressed },
|
||||
{ "refresh", w_Image_refresh },
|
||||
{ "getData", w_Image_getData },
|
||||
{ "getFlags", w_Image_getFlags },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
extern "C" int luaopen_image(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Image", functions);
|
||||
return luax_register_type(L, GRAPHICS_IMAGE_ID, functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
|
||||
Reference in New Issue
Block a user