From 2a10f8122dfccaf3cd15b4ea0b4a3b9d2ff55d6f Mon Sep 17 00:00:00 2001 From: Philip Rideout Date: Thu, 11 Oct 2018 10:23:09 -0700 Subject: [PATCH] Remove STB from web samples. Every texture now uses KTX, so there is no need to fatten the WASM with a PNG decoder. --- samples/web/CMakeLists.txt | 2 +- samples/web/filaweb.cpp | 25 ------------------------- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/samples/web/CMakeLists.txt b/samples/web/CMakeLists.txt index bfdd532aaa..4092268999 100644 --- a/samples/web/CMakeLists.txt +++ b/samples/web/CMakeLists.txt @@ -188,7 +188,7 @@ function(add_demo NAME) filaweb.h filaweb.cpp) add_dependencies(${NAME} sample_materials sample_assets) - target_link_libraries(${NAME} PRIVATE filament filagui image math utils stb) + target_link_libraries(${NAME} PRIVATE filament filagui image math utils) # Copy the generated js and wasm files into the public folder, as well as the app-specific # manually-written HTML file. diff --git a/samples/web/filaweb.cpp b/samples/web/filaweb.cpp index 5b1b931fe7..bc4ff7a7f5 100644 --- a/samples/web/filaweb.cpp +++ b/samples/web/filaweb.cpp @@ -20,11 +20,6 @@ #include -#define STB_IMAGE_IMPLEMENTATION -#define STBI_NO_STDIO -#define STBI_ONLY_PNG -#include - #include #include @@ -164,20 +159,6 @@ Asset getRawFile(const char* name) { return result; } -static Asset getPngTexture(const Asset& rawfile) { - int width, height, ncomp; - stbi_info_from_memory(rawfile.rawData.get(), rawfile.rawSize, &width, &height, &ncomp); - const uint32_t nbytes = width * height * 4; - stbi_uc* decoded = stbi_load_from_memory(rawfile.rawData.get(), rawfile.rawSize, &width, - &height, &ncomp, 4); - Asset result = {}; - result.texture.reset(new KtxBundle(1, 1, false)); - result.texture->setBlob({}, decoded, nbytes); - stbi_image_free(decoded); - return result; - -} - static Asset getKtxTexture(const Asset& rawfile) { Asset result = {}; result.texture.reset(new KtxBundle(rawfile.rawData.get(), rawfile.rawSize)); @@ -186,12 +167,6 @@ static Asset getKtxTexture(const Asset& rawfile) { Asset getTexture(const char* name) { Asset rawfile = getRawFile(name); - string extension = Path(rawfile.rawUrl).getExtension(); - fflush(stdout); - if (extension == "png" || extension == "rgbm") { - return getPngTexture(rawfile); - } - // Do not check for KTX here, sometimes we use an alternate file extension. return getKtxTexture(rawfile); }