From d1a05ce1b44a9b1305f39e412612ae38859a7b19 Mon Sep 17 00:00:00 2001 From: Almamu Date: Tue, 6 May 2025 09:37:44 +0200 Subject: [PATCH] chore: fix mipmap texture creation --- src/WallpaperEngine/Assets/CTexture.cpp | 7 +++---- src/WallpaperEngine/Assets/CTexture.h | 2 -- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/WallpaperEngine/Assets/CTexture.cpp b/src/WallpaperEngine/Assets/CTexture.cpp index e117620..d55b01a 100644 --- a/src/WallpaperEngine/Assets/CTexture.cpp +++ b/src/WallpaperEngine/Assets/CTexture.cpp @@ -135,7 +135,7 @@ void CTexture::setupOpenGLParameters (uint32_t textureID) { // set mipmap levels glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, this->m_header->mipmapCount - 1); + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, this->m_header->images [textureID].size () - 1); // setup texture wrapping and filtering if (this->m_header->flags & TextureFlags::ClampUVs) { @@ -246,7 +246,6 @@ CTexture::TextureHeader::TextureHeader () : gifHeight (0), format (TextureFormat::UNKNOWN), imageCount (0), - mipmapCount (0), isVideoMp4 (false) {} std::unique_ptr CTexture::parseHeader (const char* fileData) { @@ -306,12 +305,12 @@ std::unique_ptr CTexture::parseHeader (const char* file for (uint32_t image = 0; image < header->imageCount; image++) { // read the number of mipmaps available for this image - header->mipmapCount = *pointer++; + uint32_t mipmapCount = *pointer++; std::vector> mipmaps; fileData = reinterpret_cast (pointer); - for (uint32_t i = 0; i < header->mipmapCount; i++) + for (uint32_t i = 0; i < mipmapCount; i++) mipmaps.emplace_back (parseMipmap (header.get (), &fileData)); // add the pixmaps back diff --git a/src/WallpaperEngine/Assets/CTexture.h b/src/WallpaperEngine/Assets/CTexture.h index ecf2ea4..2c81a2b 100644 --- a/src/WallpaperEngine/Assets/CTexture.h +++ b/src/WallpaperEngine/Assets/CTexture.h @@ -141,8 +141,6 @@ class CTexture final : public ITexture { bool isVideoMp4 = false; /** The amount of images in the texture file */ uint32_t imageCount = 0; - /** Number of mipmap levels on the texture */ - uint32_t mipmapCount = 0; /** List of mipmaps */ std::map>> images {}; /** List of animation frames */