MCPcopy Create free account
hub / github.com/defold/defold / CheckAssetHandle

Function CheckAssetHandle

engine/render/src/render/render_script.cpp:1085–1103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1083 }
1084
1085 static dmGraphics::HAssetHandle CheckAssetHandle(lua_State* L, int index, dmGraphics::HContext graphics_context, dmGraphics::AssetType expected_type)
1086 {
1087 assert(lua_isnumber(L, index));
1088
1089 dmGraphics::HAssetHandle asset_handle = (dmGraphics::HAssetHandle) lua_tonumber(L, 1);
1090 if (!dmGraphics::IsAssetHandleValid(graphics_context, asset_handle))
1091 {
1092 char buf[128];
1093 luaL_error(L, "Asset handle '%s' is not valid.", AssetHandleToString(asset_handle, buf, sizeof(buf)));
1094 return (dmGraphics::HAssetHandle) -1;
1095 }
1096 else if (dmGraphics::GetAssetType(asset_handle) != expected_type)
1097 {
1098 char buf[128];
1099 luaL_error(L, "Asset handle '%s' does not have the correct type.", AssetHandleToString(asset_handle, buf, sizeof(buf)));
1100 return (dmGraphics::HAssetHandle) -1;
1101 }
1102 return asset_handle;
1103 }
1104
1105 static dmGraphics::HRenderTarget CheckRenderTarget(lua_State* L, int index, RenderScriptInstance* i)
1106 {

Callers 2

CheckRenderTargetFunction · 0.85

Calls 7

lua_isnumberFunction · 0.85
lua_tonumberFunction · 0.85
IsAssetHandleValidFunction · 0.85
luaL_errorFunction · 0.85
AssetHandleToStringFunction · 0.85
GetAssetTypeFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected