Change the 'viewformats' texture setting field to be a list of pixel formats.

Replace Texture:hasViewFormats with Texture:getViewFormats.
This commit is contained in:
Sasha Szpakowski
2024-02-24 23:42:28 -04:00
parent 42812ad521
commit e20f018272
7 changed files with 96 additions and 32 deletions
+14 -3
View File
@@ -300,10 +300,21 @@ int w_Texture_isReadable(lua_State *L)
return 1;
}
int w_Texture_hasViewFormats(lua_State *L)
int w_Texture_getViewFormats(lua_State *L)
{
Texture *t = luax_checktexture(L, 1);
luax_pushboolean(L, t->hasViewFormats());
const std::vector<PixelFormat> &viewformats = t->getViewFormats();
lua_createtable(L, (int) viewformats.size(), 0);
for (int i = 0; i < (int) viewformats.size(); i++)
{
const char *str = nullptr;
if (!getConstant(viewformats[i], str))
return luaL_error(L, "Unknown pixel format.");
lua_pushstring(L, str);
lua_rawseti(L, -2, i + 1);
}
return 1;
}
@@ -518,7 +529,7 @@ const luaL_Reg w_Texture_functions[] =
{ "isCanvas", w_Texture_isCanvas },
{ "isComputeWritable", w_Texture_isComputeWritable },
{ "isReadable", w_Texture_isReadable },
{ "hasViewFormats", w_Texture_hasViewFormats },
{ "getViewFormats", w_Texture_getViewFormats },
{ "getMipmapMode", w_Texture_getMipmapMode },
{ "getDepthSampleMode", w_Texture_getDepthSampleMode },
{ "setDepthSampleMode", w_Texture_setDepthSampleMode },