mirror of
https://github.com/overte-org/overte.git
synced 2025-04-13 21:08:35 +02:00
FIx creationg issue , need a usageType at creation
This commit is contained in:
parent
d1b91cb436
commit
2d7ba45667
4 changed files with 5 additions and 29 deletions
|
@ -1006,28 +1006,3 @@ Texture::ExternalUpdates Texture::getUpdates() const {
|
|||
}
|
||||
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;
|
||||
|
||||
static ktx::KTXUniquePointer serialize(const Texture& texture);
|
||||
static Texture* unserialize(const ktx::KTXUniquePointer& srcData);
|
||||
static Texture* unserialize(TextureUsageType usageType, const ktx::KTXUniquePointer& srcData);
|
||||
|
||||
protected:
|
||||
const TextureUsageType _usageType;
|
||||
|
|
|
@ -80,7 +80,7 @@ ktx::KTXUniquePointer Texture::serialize(const Texture& texture) {
|
|||
return ktxBuffer;
|
||||
}
|
||||
|
||||
Texture* Texture::unserialize(const ktx::KTXUniquePointer& srcData) {
|
||||
Texture* Texture::unserialize(TextureUsageType usageType, const ktx::KTXUniquePointer& srcData) {
|
||||
if (!srcData) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -105,7 +105,8 @@ Texture* Texture::unserialize(const ktx::KTXUniquePointer& srcData) {
|
|||
type = TEX_3D;
|
||||
}
|
||||
|
||||
auto tex = Texture::create( type,
|
||||
auto tex = Texture::create( usageType,
|
||||
type,
|
||||
texelFormat,
|
||||
header.getPixelWidth(),
|
||||
header.getPixelHeight(),
|
||||
|
|
|
@ -128,7 +128,7 @@ gpu::Texture* cacheTexture(const std::string& name, gpu::Texture* srcTexture, bo
|
|||
fclose (file);
|
||||
|
||||
//then create a new texture out of the ktx
|
||||
auto theNewTexure = Texture::unserialize(ktx::KTX::create(storage));
|
||||
auto theNewTexure = Texture::unserialize(gpu::TextureUsageType::RESOURCE, ktx::KTX::create(storage));
|
||||
|
||||
if (theNewTexure) {
|
||||
returnedTexture = theNewTexure;
|
||||
|
|
Loading…
Reference in a new issue