Android asset loading

This commit is contained in:
Sascha Willems 2019-08-03 18:20:27 +02:00
parent 535c693ab2
commit b67c35299b
4 changed files with 11 additions and 22 deletions

View file

@ -140,13 +140,11 @@ public:
size_t size = AAsset_getLength(asset);
assert(size > 0);
void *textureData = malloc(size);
ktx_uint8_t *textureData = new ktx_uint8_t[size];
AAsset_read(asset, textureData, size);
AAsset_close(asset);
result = ktxTexture_CreateFromMemory(textureData, size, KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT, target);
free(textureData);
result = ktxTexture_CreateFromMemory(textureData, size, KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT, &ktxTexture);
delete[] textureData;
#else
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);