chore: fix mipmap texture creation

This commit is contained in:
Almamu 2025-05-06 09:37:44 +02:00
parent bd39ce758a
commit d1a05ce1b4
2 changed files with 3 additions and 6 deletions

View File

@ -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::TextureHeader> CTexture::parseHeader (const char* fileData) {
@ -306,12 +305,12 @@ std::unique_ptr<CTexture::TextureHeader> 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<std::shared_ptr<TextureMipmap>> mipmaps;
fileData = reinterpret_cast<const char*> (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

View File

@ -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<uint32_t, std::vector<std::shared_ptr<TextureMipmap>>> images {};
/** List of animation frames */