Android texture loading

This commit is contained in:
Sascha Willems 2019-08-03 11:38:02 +02:00
parent b3be81cf98
commit 1b27063bc7

View file

@ -146,13 +146,11 @@ public:
size_t size = AAsset_getLength(asset); size_t size = AAsset_getLength(asset);
assert(size > 0); assert(size > 0);
void *textureData = malloc(size); ktx_uint8_t *textureData = new ktx_uint8_t[size];
AAsset_read(asset, textureData, size); AAsset_read(asset, textureData, size);
AAsset_close(asset); AAsset_close(asset);
result = ktxTexture_CreateFromMemory(textureData, size, KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT, &ktxTexture);
result = ktxTexture_CreateFromMemory(textureData, size, KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT, target); delete[] textureData;
free(textureData);
#else #else
if (!vks::tools::fileExists(filename)) { if (!vks::tools::fileExists(filename)) {
vks::tools::exitFatal("Could not load texture from " + filename + "\n\nThe file may be part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version.", -1); vks::tools::exitFatal("Could not load texture from " + filename + "\n\nThe file may be part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version.", -1);
@ -169,7 +167,7 @@ public:
ktx_size_t ktxTextureSize = ktxTexture_GetSize(ktxTexture); ktx_size_t ktxTextureSize = ktxTexture_GetSize(ktxTexture);
// We prefer using staging to copy the texture data to a device local optimal image // We prefer using staging to copy the texture data to a device local optimal image
VkBool32 useStaging = false; VkBool32 useStaging = true;
// Only use linear tiling if forced // Only use linear tiling if forced
bool forceLinearTiling = false; bool forceLinearTiling = false;