mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
Merge pull request #9736 from jherico/smarter_textures
Smarter textures
This commit is contained in:
commit
5007d77e56
2 changed files with 6 additions and 6 deletions
|
@ -77,7 +77,7 @@ ktx::KTXUniquePointer Texture::serialize(const Texture& texture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Number level of mips coming
|
// Number level of mips coming
|
||||||
header.numberOfMipmapLevels = texture.maxMip();
|
header.numberOfMipmapLevels = texture.maxMip() + 1;
|
||||||
|
|
||||||
ktx::Images images;
|
ktx::Images images;
|
||||||
for (uint32_t level = 0; level < header.numberOfMipmapLevels; level++) {
|
for (uint32_t level = 0; level < header.numberOfMipmapLevels; level++) {
|
||||||
|
|
|
@ -96,7 +96,7 @@ gpu::Texture* cacheTexture(const std::string& name, gpu::Texture* srcTexture, bo
|
||||||
// Prepare cache directory
|
// Prepare cache directory
|
||||||
static const QString HIFI_KTX_FOLDER("hifi_ktx");
|
static const QString HIFI_KTX_FOLDER("hifi_ktx");
|
||||||
QString docsLocation = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
QString docsLocation = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||||
ktxCacheFolder = docsLocation + "/" + HIFI_KTX_FOLDER;
|
ktxCacheFolder = docsLocation + "/" + HIFI_KTX_FOLDER + "/";
|
||||||
QFileInfo info(ktxCacheFolder);
|
QFileInfo info(ktxCacheFolder);
|
||||||
if (!info.exists()) {
|
if (!info.exists()) {
|
||||||
QDir(docsLocation).mkpath(HIFI_KTX_FOLDER);
|
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()) {
|
if (read && QFileInfo(cacheFilename.c_str()).exists()) {
|
||||||
#define DEBUG_KTX_LOADING 1
|
#define DEBUG_KTX_LOADING 0
|
||||||
#ifdef DEBUG_KTX_LOADING
|
#if DEBUG_KTX_LOADING
|
||||||
{
|
{
|
||||||
FILE* file = fopen(cacheFilename.c_str(), "rb");
|
FILE* file = fopen(cacheFilename.c_str(), "rb");
|
||||||
if (file != nullptr) {
|
if (file != nullptr) {
|
||||||
|
@ -157,12 +157,12 @@ gpu::Texture* cacheTexture(const std::string& name, gpu::Texture* srcTexture, bo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
auto ktxFile = ktx::KTX::create(std::unique_ptr<storage::Storage>(new storage::FileStorage(cacheFilename.c_str())));
|
ktx::StoragePointer storage = std::make_shared<storage::FileStorage>(cacheFilename.c_str());
|
||||||
|
auto ktxFile = ktx::KTX::create(storage);
|
||||||
returnedTexture->setKtxBacking(ktxFile);
|
returnedTexture->setKtxBacking(ktxFile);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnedTexture;
|
return returnedTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue