From e1b498f82ce2c17f57201622ae331f92bb0e1f17 Mon Sep 17 00:00:00 2001 From: Philip Rideout Date: Tue, 28 Jan 2020 10:19:11 -0800 Subject: [PATCH] Repair iOS error due to STBI_NO_STDIO. Fixes #2072. --- libs/gltfio/include/gltfio/Image.h | 5 +++++ libs/gltfio/src/ResourceLoader.cpp | 7 +++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libs/gltfio/include/gltfio/Image.h b/libs/gltfio/include/gltfio/Image.h index 6cce107454..c2bc2023ea 100644 --- a/libs/gltfio/include/gltfio/Image.h +++ b/libs/gltfio/include/gltfio/Image.h @@ -22,6 +22,11 @@ #define STBI_NO_HDR #define STBI_NO_PIC #define STBI_NO_PNM + +// For emscripten and Android builds, we never load from the file +// system, so we-opt out of the stdio functionality in stb. +#if defined(__EMSCRIPTEN__) || defined(ANDROID) #define STBI_NO_STDIO +#endif #include diff --git a/libs/gltfio/src/ResourceLoader.cpp b/libs/gltfio/src/ResourceLoader.cpp index bc1e7ec864..0dc8eb856f 100644 --- a/libs/gltfio/src/ResourceLoader.cpp +++ b/libs/gltfio/src/ResourceLoader.cpp @@ -15,6 +15,7 @@ */ #include +#include #include "FFilamentAsset.h" #include "upcast.h" @@ -36,8 +37,6 @@ #include -#include - #include #include @@ -147,7 +146,7 @@ bool ResourceLoader::loadResources(FilamentAsset* asset) { // looks inside a cache of externally-supplied data blobs, rather than loading from the // filesystem. - #if defined(__EMSCRIPTEN__) || defined(ANDROID) + #if defined(STBI_NO_STDIO) if (gltf->buffers_count && !gltf->buffers[0].data && !gltf->buffers[0].uri && gltf->bin) { if (gltf->bin_size < gltf->buffers[0].size) { @@ -378,7 +377,7 @@ bool ResourceLoader::createTextures(details::FFilamentAsset* asset) const { js->run(decode); } } else { - #if defined(__EMSCRIPTEN__) || defined(ANDROID) + #if defined(STBI_NO_STDIO) slog.e << "Unable to load texture: " << tb.uri << io::endl; return false; #else