* Fixes to fancy pants grass detection, etc.

This commit is contained in:
iProgramInCpp
2023-12-26 01:18:54 +02:00
parent 7f219385c6
commit 7eae466865
13 changed files with 56 additions and 32 deletions

View File

@@ -134,7 +134,7 @@ std::string AppPlatform_android::getDateString(int time)
return std::string(buffer);
}
Texture AppPlatform_android::loadTexture(const std::string& str, bool b)
Texture AppPlatform_android::loadTexture(const std::string& str, bool bIsRequired)
{
std::string realPath = str;
if (realPath.size() && realPath[0] == '/')
@@ -144,19 +144,22 @@ Texture AppPlatform_android::loadTexture(const std::string& str, bool b)
AAsset* asset = AAssetManager_open(m_app->activity->assetManager, str.c_str(), AASSET_MODE_BUFFER);
if (!asset) {
LOG_E("File %s couldn't be opened", realPath.c_str());
assert(!bIsRequired && "Hey, a texture couldn't be loaded");
return Texture(0, 0, nullptr, 1, 0);
}
size_t cnt = AAsset_getLength(asset);
unsigned char* buffer = (unsigned char*)calloc(cnt, sizeof(unsigned char));
AAsset_read(asset, (void*)buffer, cnt);
AAsset_close(asset);
int width = 0, height = 0, channels = 0;
stbi_uc* img = stbi_load_from_memory(buffer, cnt, &width, &height, &channels, STBI_rgb_alpha);
if (!img)
{
LOG_E("File %s couldn't be loaded via stb_image", realPath.c_str());
assert(!bIsRequired && "Hey, a texture couldn't be loaded");
return Texture(0, 0, nullptr, 1, 0);
}
free(buffer);