mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 05:05:19 -05:00
fix: OpenGL textures not being cleaned up correctly
This commit is contained in:
@@ -960,10 +960,10 @@ namespace hex::plugin::builtin {
|
||||
NodeVisualizerImage() : Node("hex.builtin.nodes.visualizer.image.header", { dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.common.input") }) { }
|
||||
|
||||
void drawNode() override {
|
||||
ImGui::Image(this->m_texture, scaled(ImVec2(this->m_texture.aspectRatio() * 200, 200)));
|
||||
ImGui::Image(this->m_texture, scaled(ImVec2(this->m_texture.getAspectRatio() * 200, 200)));
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Image(this->m_texture, scaled(ImVec2(this->m_texture.aspectRatio() * 600, 600)));
|
||||
ImGui::Image(this->m_texture, scaled(ImVec2(this->m_texture.getAspectRatio() * 600, 600)));
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
}
|
||||
@@ -971,10 +971,7 @@ namespace hex::plugin::builtin {
|
||||
void process() override {
|
||||
auto rawData = this->getBufferOnInput(0);
|
||||
|
||||
if (this->m_texture.valid())
|
||||
ImGui::UnloadImage(this->m_texture);
|
||||
|
||||
this->m_texture = ImGui::LoadImageFromMemory(rawData.data(), rawData.size());
|
||||
this->m_texture = ImGui::Texture(rawData.data(), rawData.size());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -25,10 +25,6 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
}
|
||||
|
||||
ViewAbout::~ViewAbout() {
|
||||
ImGui::UnloadImage(this->m_logoTexture);
|
||||
}
|
||||
|
||||
static void link(const std::string &name, const std::string &author, const std::string &url) {
|
||||
if (ImGui::BulletHyperlink(name.c_str()))
|
||||
hex::openWebpage(url);
|
||||
@@ -50,12 +46,12 @@ namespace hex::plugin::builtin {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
if (!this->m_logoTexture.valid()) {
|
||||
if (!this->m_logoTexture.isValid()) {
|
||||
auto logo = romfs::get("logo.png");
|
||||
this->m_logoTexture = ImGui::LoadImageFromMemory(reinterpret_cast<const ImU8 *>(logo.data()), logo.size());
|
||||
this->m_logoTexture = ImGui::Texture(reinterpret_cast<const ImU8 *>(logo.data()), logo.size());
|
||||
}
|
||||
|
||||
ImGui::Image(this->m_logoTexture.textureId, scaled({ 64, 64 }));
|
||||
ImGui::Image(this->m_logoTexture, scaled({ 64, 64 }));
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::TextFormatted("ImHex Hex Editor v{} by WerWolv - " ICON_FA_CODE_BRANCH, IMHEX_VERSION);
|
||||
|
||||
@@ -182,7 +182,7 @@ namespace hex::plugin::builtin {
|
||||
static void drawWelcomeScreenContent() {
|
||||
const auto availableSpace = ImGui::GetContentRegionAvail();
|
||||
|
||||
ImGui::Image(s_bannerTexture, s_bannerTexture.size() / (2 * (1.0F / ImHexApi::System::getGlobalScale())));
|
||||
ImGui::Image(s_bannerTexture, s_bannerTexture.getSize() / (2 * (1.0F / ImHexApi::System::getGlobalScale())));
|
||||
|
||||
ImGui::Indent();
|
||||
if (ImGui::BeginTable("Welcome Left", 1, ImGuiTableFlags_NoBordersInBody, ImVec2(availableSpace.x / 2, 0))) {
|
||||
@@ -432,14 +432,10 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
(void)EventManager::subscribe<RequestChangeTheme>([](u32 theme) {
|
||||
auto changeTexture = [&](const std::string &path, const ImGui::Texture &texture) {
|
||||
auto changeTexture = [&](const std::string &path) {
|
||||
auto textureData = romfs::get(path);
|
||||
auto oldTexture = texture;
|
||||
auto newTexture = ImGui::LoadImageFromMemory(reinterpret_cast<const ImU8 *>(textureData.data()), textureData.size());
|
||||
|
||||
if (oldTexture.valid()) { ImGui::UnloadImage(oldTexture); }
|
||||
|
||||
return newTexture;
|
||||
return ImGui::Texture(reinterpret_cast<const ImU8*>(textureData.data()), textureData.size());
|
||||
};
|
||||
|
||||
switch (theme) {
|
||||
@@ -449,8 +445,8 @@ namespace hex::plugin::builtin {
|
||||
ImGui::StyleColorsDark();
|
||||
ImGui::StyleCustomColorsDark();
|
||||
ImPlot::StyleColorsDark();
|
||||
s_bannerTexture = changeTexture("banner_dark.png", s_bannerTexture);
|
||||
s_backdropTexture = changeTexture("backdrop_dark.png", s_backdropTexture);
|
||||
s_bannerTexture = changeTexture("banner_dark.png");
|
||||
s_backdropTexture = changeTexture("backdrop_dark.png");
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -459,8 +455,8 @@ namespace hex::plugin::builtin {
|
||||
ImGui::StyleColorsLight();
|
||||
ImGui::StyleCustomColorsLight();
|
||||
ImPlot::StyleColorsLight();
|
||||
s_bannerTexture = changeTexture("banner_light.png", s_bannerTexture);
|
||||
s_backdropTexture = changeTexture("backdrop_light.png", s_backdropTexture);
|
||||
s_bannerTexture = changeTexture("banner_light.png");
|
||||
s_backdropTexture = changeTexture("backdrop_light.png");
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -469,8 +465,8 @@ namespace hex::plugin::builtin {
|
||||
ImGui::StyleColorsClassic();
|
||||
ImGui::StyleCustomColorsClassic();
|
||||
ImPlot::StyleColorsClassic();
|
||||
s_bannerTexture = changeTexture("banner_dark.png", s_bannerTexture);
|
||||
s_backdropTexture = changeTexture("backdrop_dark.png", s_backdropTexture);
|
||||
s_bannerTexture = changeTexture("banner_dark.png");
|
||||
s_backdropTexture = changeTexture("backdrop_dark.png");
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -481,7 +477,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::GetStyle().Colors[ImGuiCol_TitleBgActive] = ImGui::GetStyle().Colors[ImGuiCol_MenuBarBg];
|
||||
ImGui::GetStyle().Colors[ImGuiCol_TitleBgCollapsed] = ImGui::GetStyle().Colors[ImGuiCol_MenuBarBg];
|
||||
|
||||
if (!s_bannerTexture.valid()) {
|
||||
if (!s_bannerTexture.isValid()) {
|
||||
log::error("Failed to load banner texture!");
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user