mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 20:42:56 +02:00
Merge pull request #9700 from samcake/brown
FIx creationg issue , need a usageType at creation
This commit is contained in:
commit
3ed051317b
4 changed files with 5 additions and 29 deletions
|
@ -1006,28 +1006,3 @@ Texture::ExternalUpdates Texture::getUpdates() const {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <ktx/KTX.h>
|
|
||||||
|
|
||||||
ktx::KTXUniquePointer Texture::serialize(const Texture& texture) {
|
|
||||||
|
|
||||||
ktx::Header header;
|
|
||||||
header.setUncompressed(ktx::GLType::UNSIGNED_BYTE, 4, ktx::GLFormat::BGRA, ktx::GLInternalFormat_Uncompressed::RGBA8, ktx::GLBaseInternalFormat::RGBA);
|
|
||||||
header.pixelWidth = texture.getWidth();
|
|
||||||
header.pixelHeight = texture.getHeight();
|
|
||||||
header.numberOfMipmapLevels = texture.mipLevels();
|
|
||||||
|
|
||||||
ktx::Images images;
|
|
||||||
for (int level = 0; level < header.numberOfMipmapLevels; level++) {
|
|
||||||
auto mip = texture.accessStoredMipFace(level);
|
|
||||||
if (mip) {
|
|
||||||
images.emplace_back(ktx::Image(mip->getSize(), 0, mip->readData()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto ktxBuffer = ktx::KTX::create(header, ktx::KeyValues(), images);
|
|
||||||
return ktxBuffer;
|
|
||||||
}
|
|
||||||
TexturePointer Texture::unserialize(const ktx::KTXUniquePointer& srcData) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
|
@ -493,7 +493,7 @@ public:
|
||||||
ExternalUpdates getUpdates() const;
|
ExternalUpdates getUpdates() const;
|
||||||
|
|
||||||
static ktx::KTXUniquePointer serialize(const Texture& texture);
|
static ktx::KTXUniquePointer serialize(const Texture& texture);
|
||||||
static Texture* unserialize(const ktx::KTXUniquePointer& srcData);
|
static Texture* unserialize(TextureUsageType usageType, const ktx::KTXUniquePointer& srcData);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const TextureUsageType _usageType;
|
const TextureUsageType _usageType;
|
||||||
|
|
|
@ -80,7 +80,7 @@ ktx::KTXUniquePointer Texture::serialize(const Texture& texture) {
|
||||||
return ktxBuffer;
|
return ktxBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture* Texture::unserialize(const ktx::KTXUniquePointer& srcData) {
|
Texture* Texture::unserialize(TextureUsageType usageType, const ktx::KTXUniquePointer& srcData) {
|
||||||
if (!srcData) {
|
if (!srcData) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,8 @@ Texture* Texture::unserialize(const ktx::KTXUniquePointer& srcData) {
|
||||||
type = TEX_3D;
|
type = TEX_3D;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto tex = Texture::create( type,
|
auto tex = Texture::create( usageType,
|
||||||
|
type,
|
||||||
texelFormat,
|
texelFormat,
|
||||||
header.getPixelWidth(),
|
header.getPixelWidth(),
|
||||||
header.getPixelHeight(),
|
header.getPixelHeight(),
|
||||||
|
|
|
@ -128,7 +128,7 @@ gpu::Texture* cacheTexture(const std::string& name, gpu::Texture* srcTexture, bo
|
||||||
fclose (file);
|
fclose (file);
|
||||||
|
|
||||||
//then create a new texture out of the ktx
|
//then create a new texture out of the ktx
|
||||||
auto theNewTexure = Texture::unserialize(ktx::KTX::create(storage));
|
auto theNewTexure = Texture::unserialize(srcTexture->getUsageType(), ktx::KTX::create(storage));
|
||||||
|
|
||||||
if (theNewTexure) {
|
if (theNewTexure) {
|
||||||
returnedTexture = theNewTexure;
|
returnedTexture = theNewTexure;
|
||||||
|
|
Loading…
Reference in a new issue