From f32817beacad647222aa4a89e943b18194b2ba40 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Thu, 23 Feb 2017 10:19:20 -0800 Subject: [PATCH 1/2] Fix number of mips calculation --- libraries/gpu/src/gpu/Texture_ktx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/gpu/src/gpu/Texture_ktx.cpp b/libraries/gpu/src/gpu/Texture_ktx.cpp index 83d8e20b1c..d18440bbc6 100644 --- a/libraries/gpu/src/gpu/Texture_ktx.cpp +++ b/libraries/gpu/src/gpu/Texture_ktx.cpp @@ -77,7 +77,7 @@ ktx::KTXUniquePointer Texture::serialize(const Texture& texture) { } // Number level of mips coming - header.numberOfMipmapLevels = texture.maxMip(); + header.numberOfMipmapLevels = texture.maxMip() + 1; ktx::Images images; for (uint32_t level = 0; level < header.numberOfMipmapLevels; level++) { From a168bbf2dda4d3b628b43c3830cfa4cce8f78b7a Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Thu, 23 Feb 2017 10:26:59 -0800 Subject: [PATCH 2/2] Fix ktx file location, unique->shared pointer --- libraries/model/src/model/TextureMap.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/model/src/model/TextureMap.cpp b/libraries/model/src/model/TextureMap.cpp index a3bd5fc7c1..dd0ae402d5 100755 --- a/libraries/model/src/model/TextureMap.cpp +++ b/libraries/model/src/model/TextureMap.cpp @@ -96,7 +96,7 @@ gpu::Texture* cacheTexture(const std::string& name, gpu::Texture* srcTexture, bo // Prepare cache directory static const QString HIFI_KTX_FOLDER("hifi_ktx"); QString docsLocation = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); - ktxCacheFolder = docsLocation + "/" + HIFI_KTX_FOLDER; + ktxCacheFolder = docsLocation + "/" + HIFI_KTX_FOLDER + "/"; QFileInfo info(ktxCacheFolder); if (!info.exists()) { QDir(docsLocation).mkpath(HIFI_KTX_FOLDER); @@ -132,8 +132,8 @@ gpu::Texture* cacheTexture(const std::string& name, gpu::Texture* srcTexture, bo } if (read && QFileInfo(cacheFilename.c_str()).exists()) { -#define DEBUG_KTX_LOADING 1 -#ifdef DEBUG_KTX_LOADING +#define DEBUG_KTX_LOADING 0 +#if DEBUG_KTX_LOADING { FILE* file = fopen(cacheFilename.c_str(), "rb"); if (file != nullptr) { @@ -157,12 +157,12 @@ gpu::Texture* cacheTexture(const std::string& name, gpu::Texture* srcTexture, bo } } #else - auto ktxFile = ktx::KTX::create(std::unique_ptr(new storage::FileStorage(cacheFilename.c_str()))); + ktx::StoragePointer storage = std::make_shared(cacheFilename.c_str()); + auto ktxFile = ktx::KTX::create(storage); returnedTexture->setKtxBacking(ktxFile); #endif } } - return returnedTexture; }