diff --git a/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h b/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h index 7efd7fed3..91b2c44c8 100644 --- a/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h +++ b/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h @@ -79,17 +79,16 @@ namespace ImGuiExt { Texture(const Texture&) = delete; Texture(Texture&& other) noexcept; - [[nodiscard]] static Texture fromImage(const ImU8 *buffer, int size, Filter filter = Filter::Nearest); - [[nodiscard]] static Texture fromImage(std::span buffer, Filter filter = Filter::Nearest); - [[nodiscard]] static Texture fromImage(const char *path, Filter filter = Filter::Nearest); - [[nodiscard]] static Texture fromImage(const std::fs::path &path, Filter filter = Filter::Nearest); - [[nodiscard]] static Texture fromGLTexture(unsigned int texture, int width, int height); - [[nodiscard]] static Texture fromBitmap(const ImU8 *buffer, int size, int width, int height, Filter filter = Filter::Nearest); - [[nodiscard]] static Texture fromBitmap(std::span buffer, int width, int height, Filter filter = Filter::Nearest); - [[nodiscard]] static Texture fromSVG(const char *path, int width = 0, int height = 0, Filter filter = Filter::Nearest); - [[nodiscard]] static Texture fromSVG(const std::fs::path &path, int width = 0, int height = 0, Filter filter = Filter::Nearest); - [[nodiscard]] static Texture fromSVG(std::span buffer, int width = 0, int height = 0, Filter filter = Filter::Nearest); - + [[nodiscard]] static Texture fromImage(const ImU8 *buffer, int size, Filter filter = Filter::Nearest); + [[nodiscard]] static Texture fromImage(std::span buffer, Filter filter = Filter::Nearest); + [[nodiscard]] static Texture fromImage(const char *path, Filter filter = Filter::Nearest); + [[nodiscard]] static Texture fromImage(const std::fs::path &path, Filter filter = Filter::Nearest); + [[nodiscard]] static Texture fromGLTexture(unsigned int texture, int width, int height); + [[nodiscard]] static Texture fromBitmap(const ImU8 *buffer, int size, int width, int height, Filter filter = Filter::Nearest); + [[nodiscard]] static Texture fromBitmap(std::span buffer, int width, int height, Filter filter = Filter::Nearest); + [[nodiscard]] static Texture fromSVG(const char *path, int width = 0, int height = 0, Filter filter = Filter::Nearest); + [[nodiscard]] static Texture fromSVG(const std::fs::path &path, int width = 0, int height = 0, Filter filter = Filter::Nearest); + [[nodiscard]] static Texture fromSVG(std::span buffer, int width = 0, int height = 0, Filter filter = Filter::Nearest); ~Texture(); @@ -114,6 +113,8 @@ namespace ImGuiExt { return float(m_width) / float(m_height); } + void reset(); + private: ImTextureID m_textureId = 0; int m_width = 0, m_height = 0; diff --git a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp index 61faffb28..524a3130b 100644 --- a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp +++ b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp @@ -284,10 +284,14 @@ namespace ImGuiExt { } Texture::~Texture() { - if (m_textureId == 0) - return; + this->reset(); + } - glDeleteTextures(1, reinterpret_cast(&m_textureId)); + void Texture::reset() { + if (m_textureId != 0) { + glDeleteTextures(1, reinterpret_cast(&m_textureId)); + m_textureId = 0; + } } float GetTextWrapPos() { diff --git a/main/gui/source/init/splash_window.cpp b/main/gui/source/init/splash_window.cpp index 4ed8fe493..3f9e88c22 100644 --- a/main/gui/source/init/splash_window.cpp +++ b/main/gui/source/init/splash_window.cpp @@ -65,6 +65,10 @@ namespace hex::init { } WindowSplash::~WindowSplash() { + // Clear textures before deinitializing glfw + m_splashBackgroundTexture.reset(); + m_splashTextTexture.reset(); + this->exitImGui(); this->exitGLFW(); } @@ -584,7 +588,6 @@ namespace hex::init { void WindowSplash::exitGLFW() const { glfwDestroyWindow(m_window); - glfwTerminate(); } void WindowSplash::exitImGui() const {