Fix Texture Detection

This commit is contained in:
TheBrokenRail
2023-11-05 17:03:07 -05:00
committed by iProgramInCpp
parent ec12755632
commit 433b1532d9
7 changed files with 47 additions and 22 deletions

View File

@@ -28,3 +28,23 @@ Texture AppPlatform_sdl::loadTexture(const std::string& path, bool b)
LOG_E("Couldn't find file: %s", realPath.c_str());
return out;
}
bool AppPlatform_sdl::doesTextureExist(const std::string& path)
{
// Get Full Path
std::string realPath = getAssetPath(path);
// Open File
int width = 0, height = 0;
char *data = emscripten_get_preloaded_image_data(("/" + realPath).c_str(), &width, &height);
if (!data)
{
// Does Not Exist
return false;
}
else
{
// File Exists
free(data);
return true;
}
}