mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-01 21:17:44 -05:00
fix: Make sure all textures are destroyed before glfw gets uninitialized
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <romfs/romfs.hpp>
|
||||
#include <numeric>
|
||||
#include <hex/helpers/auto_reset.hpp>
|
||||
|
||||
namespace hex::plugin::visualizers {
|
||||
|
||||
@@ -85,7 +86,7 @@ namespace hex::plugin::visualizers {
|
||||
|
||||
IndexType s_indexType;
|
||||
|
||||
ImGuiExt::Texture s_modelTexture;
|
||||
AutoReset<ImGuiExt::Texture> s_modelTexture;
|
||||
|
||||
gl::Vector<float, 3> s_translation = { { 0.0F, 0.0F, -3.0F } };
|
||||
gl::Vector<float, 3> s_rotation = { { 0.0F, 0.0F, 0.0F } };
|
||||
@@ -94,7 +95,7 @@ namespace hex::plugin::visualizers {
|
||||
gl::Vector<float, 3> s_lightColor = { { 1.0F, 1.0F, 1.0F } };
|
||||
gl::Matrix<float, 4, 4> s_rotate = gl::Matrix<float, 4, 4>::identity();
|
||||
|
||||
ImGuiExt::Texture s_texture;
|
||||
AutoReset<ImGuiExt::Texture> s_texture;
|
||||
std::fs::path s_texturePath;
|
||||
|
||||
u32 s_vertexCount;
|
||||
@@ -806,7 +807,7 @@ namespace hex::plugin::visualizers {
|
||||
}
|
||||
|
||||
if (s_drawTexture)
|
||||
glBindTexture(GL_TEXTURE_2D, s_modelTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, *s_modelTexture);
|
||||
|
||||
buffers.indices.bind();
|
||||
if (buffers.indices.getSize() == 0)
|
||||
@@ -938,4 +939,4 @@ namespace hex::plugin::visualizers {
|
||||
processRendering<u8>(verticesPattern, indicesPattern, normalsPattern, colorsPattern, uvPattern);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <content/visualizer_helpers.hpp>
|
||||
|
||||
#include <imgui.h>
|
||||
#include <hex/helpers/auto_reset.hpp>
|
||||
|
||||
#include <hex/ui/imgui_imhex_extensions.h>
|
||||
|
||||
@@ -12,7 +13,7 @@ namespace hex::plugin::visualizers {
|
||||
|
||||
|
||||
void drawImageVisualizer(pl::ptrn::Pattern &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
static ImGuiExt::Texture texture;
|
||||
static AutoReset<ImGuiExt::Texture> texture;
|
||||
static float scale = 1.0F;
|
||||
|
||||
if (shouldReset) {
|
||||
@@ -20,11 +21,11 @@ namespace hex::plugin::visualizers {
|
||||
|
||||
auto data = pattern->getBytes();
|
||||
texture = ImGuiExt::Texture::fromImage(data.data(), data.size(), ImGuiExt::Texture::Filter::Nearest);
|
||||
scale = 200_scaled / texture.getSize().x;
|
||||
scale = 200_scaled / texture->getSize().x;
|
||||
}
|
||||
|
||||
if (texture.isValid())
|
||||
ImGui::Image(texture, texture.getSize() * scale);
|
||||
ImGui::Image(*texture, texture->getSize() * scale);
|
||||
|
||||
if (ImGui::IsWindowHovered()) {
|
||||
auto scrollDelta = ImGui::GetIO().MouseWheel;
|
||||
@@ -36,7 +37,7 @@ namespace hex::plugin::visualizers {
|
||||
}
|
||||
|
||||
void drawBitmapVisualizer(pl::ptrn::Pattern &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
static ImGuiExt::Texture texture;
|
||||
static AutoReset<ImGuiExt::Texture> texture;
|
||||
static float scale = 1.0F;
|
||||
|
||||
if (shouldReset) {
|
||||
@@ -62,7 +63,7 @@ namespace hex::plugin::visualizers {
|
||||
}
|
||||
|
||||
if (texture.isValid())
|
||||
ImGui::Image(texture, texture.getSize() * scale);
|
||||
ImGui::Image(*texture, texture->getSize() * scale);
|
||||
|
||||
if (ImGui::IsWindowHovered()) {
|
||||
auto scrollDelta = ImGui::GetIO().MouseWheel;
|
||||
|
||||
Reference in New Issue
Block a user