mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
write the source hash in ktx header in binary
This commit is contained in:
parent
927efc88f0
commit
3c5754282f
2 changed files with 8 additions and 1 deletions
|
@ -35,6 +35,7 @@ namespace ktx {
|
|||
namespace gpu {
|
||||
|
||||
extern const std::string SOURCE_HASH_KEY;
|
||||
const uint8 SOURCE_HASH_BYTES = 16;
|
||||
|
||||
// THe spherical harmonics is a nice tool for cubemap, so if required, the irradiance SH can be automatically generated
|
||||
// with the cube texture
|
||||
|
|
|
@ -13,7 +13,10 @@
|
|||
#include "Texture.h"
|
||||
#include <qdebug.h>
|
||||
|
||||
#include <QtCore/QByteArray>
|
||||
|
||||
#include <ktx/KTX.h>
|
||||
|
||||
using namespace gpu;
|
||||
|
||||
using PixelsPointer = Texture::PixelsPointer;
|
||||
|
@ -312,7 +315,10 @@ ktx::KTXUniquePointer Texture::serialize(const Texture& texture) {
|
|||
|
||||
auto hash = texture.sourceHash();
|
||||
if (!hash.empty()) {
|
||||
keyValues.emplace_back(SOURCE_HASH_KEY, static_cast<uint32>(hash.size()), (ktx::Byte*) hash.c_str());
|
||||
// the sourceHash is an std::string in hex
|
||||
// we use QByteArray to take the hex and turn it into the smaller binary representation (16 bytes)
|
||||
auto binaryHash = QByteArray::fromHex(QByteArray::fromStdString(hash));
|
||||
keyValues.emplace_back(SOURCE_HASH_KEY, static_cast<uint32>(binaryHash.size()), (ktx::Byte*) binaryHash.data());
|
||||
}
|
||||
|
||||
auto ktxBuffer = ktx::KTX::create(header, images, keyValues);
|
||||
|
|
Loading…
Reference in a new issue