Преглед изворни кода

chore: free allocated textures

Almamu пре 7 месеци
родитељ
комит
ed34eefa03
2 измењених фајлова са 9 додато и 0 уклоњено
  1. 8 0
      src/WallpaperEngine/Render/CTexture.cpp
  2. 1 0
      src/WallpaperEngine/Render/CTexture.h

+ 8 - 0
src/WallpaperEngine/Render/CTexture.cpp

@@ -79,6 +79,14 @@ CTexture::CTexture (TextureUniquePtr header) : m_header (std::move (header)) {
     }
     }
 }
 }
 
 
+CTexture::~CTexture () {
+    for (uint32_t i = 0; i < this->m_header->imageCount; i++) {
+        glDeleteTextures (1, &this->m_textureID[i]);
+    }
+
+    delete[] this->m_textureID;
+}
+
 void CTexture::setupResolution () {
 void CTexture::setupResolution () {
     if (this->isAnimated ()) {
     if (this->isAnimated ()) {
 	this->m_resolution = { this->m_header->textureWidth, this->m_header->textureHeight, this->m_header->gifWidth,
 	this->m_resolution = { this->m_header->textureWidth, this->m_header->textureHeight, this->m_header->gifWidth,

+ 1 - 0
src/WallpaperEngine/Render/CTexture.h

@@ -17,6 +17,7 @@ using namespace WallpaperEngine::Data::Assets;
 class CTexture final : public TextureProvider {
 class CTexture final : public TextureProvider {
 public:
 public:
     explicit CTexture (TextureUniquePtr header);
     explicit CTexture (TextureUniquePtr header);
+    ~CTexture () override;
 
 
     [[nodiscard]] GLuint getTextureID (uint32_t imageIndex) const override;
     [[nodiscard]] GLuint getTextureID (uint32_t imageIndex) const override;
     [[nodiscard]] uint32_t getTextureWidth (uint32_t imageIndex) const override;
     [[nodiscard]] uint32_t getTextureWidth (uint32_t imageIndex) const override;