lovr.data.newTextureData can create empty textures;
@@ -35,10 +35,19 @@ int l_lovrDataNewModelData(lua_State* L) {
}
int l_lovrDataNewTextureData(lua_State* L) {
+ TextureData* textureData = NULL;
+ if (lua_type(L, 1) == LUA_TNUMBER) {
+ int width = luaL_checknumber(L, 1);
+ int height = luaL_checknumber(L, 2);
+ lovrAssert(width > 0 && height > 0, "TextureData dimensions must be positive");
+ textureData = lovrTextureDataGetBlank(width, height, 0x0, FORMAT_RGBA);
+ } else {
Blob* blob = luax_readblob(L, 1, "Texture");
- TextureData* textureData = lovrTextureDataFromBlob(blob);
- luax_pushtype(L, TextureData, textureData);
+ textureData = lovrTextureDataFromBlob(blob);
lovrRelease(&blob->ref);
+ }
+
+ luax_pushtype(L, TextureData, textureData);
lovrRelease(&textureData->ref);
return 1;
}
