diff --git a/.gitmodules b/.gitmodules index 4eba152b8..78bb29458 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,6 +22,15 @@ path = lib/third_party/jthread/jthread url = https://github.com/josuttis/jthread ignore = dirty + url = https://github.com/WerWolv/HashLibPlus +[submodule "lib/third_party/edlib"] + path = lib/third_party/edlib + url = https://github.com/Martinsos/edlib + ignore = dirty +[submodule "lib/third_party/lunasvg"] + path = lib/third_party/lunasvg + url = https://github.com/sammycage/lunasvg + ignore = dirty [submodule "lib/external/libromfs"] path = lib/external/libromfs @@ -34,8 +43,4 @@ url = https://github.com/WerWolv/libwolv [submodule "lib/third_party/HashLibPlus"] - path = lib/third_party/HashLibPlus - url = https://github.com/WerWolv/HashLibPlus -[submodule "lib/third_party/edlib"] - path = lib/third_party/edlib - url = https://github.com/Martinsos/edlib + path = lib/third_party/HashLibPlus \ No newline at end of file diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index b869ba11b..dd1dc0a5a 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -596,6 +596,14 @@ macro(addBundledLibraries) set(NLOHMANN_JSON_LIBRARIES nlohmann_json::nlohmann_json) endif() + if (NOT USE_SYSTEM_LUNASVG) + add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/lunasvg EXCLUDE_FROM_ALL) + set(LUNASVG_LIBRARIES lunasvg) + else() + find_package(LunaSVG REQUIRED) + set(LUNASVG_LIBRARIES lunasvg) + endif() + if (NOT USE_SYSTEM_LLVM) add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/llvm-demangle EXCLUDE_FROM_ALL) else() diff --git a/lib/libimhex/CMakeLists.txt b/lib/libimhex/CMakeLists.txt index 93ec82a41..478a67065 100644 --- a/lib/libimhex/CMakeLists.txt +++ b/lib/libimhex/CMakeLists.txt @@ -142,7 +142,7 @@ if (NOT IMHEX_EXTERNAL_PLUGIN_BUILD) precompileHeaders(libimhex "${CMAKE_CURRENT_SOURCE_DIR}/include") endif() -target_link_libraries(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${NLOHMANN_JSON_LIBRARIES} imgui_all_includes ${MBEDTLS_LIBRARIES} ${FMT_LIBRARIES}) +target_link_libraries(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${NLOHMANN_JSON_LIBRARIES} imgui_all_includes ${MBEDTLS_LIBRARIES} ${FMT_LIBRARIES} ${LUNASVG_LIBRARIES}) set_property(TARGET libimhex PROPERTY INTERPROCEDURAL_OPTIMIZATION FALSE) diff --git a/lib/libimhex/include/hex/api/achievement_manager.hpp b/lib/libimhex/include/hex/api/achievement_manager.hpp index 3fb80ce19..64e28cd89 100644 --- a/lib/libimhex/include/hex/api/achievement_manager.hpp +++ b/lib/libimhex/include/hex/api/achievement_manager.hpp @@ -151,7 +151,7 @@ namespace hex { if (m_icon.isValid()) return m_icon; - m_icon = ImGuiExt::Texture(m_iconData.data(), m_iconData.size(), ImGuiExt::Texture::Filter::Linear); + m_icon = ImGuiExt::Texture::fromImage(m_iconData.data(), m_iconData.size(), ImGuiExt::Texture::Filter::Linear); return m_icon; } diff --git a/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h b/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h index f834f1c44..07de63df3 100644 --- a/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h +++ b/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h @@ -76,14 +76,21 @@ namespace ImGuiExt { }; Texture() = default; - Texture(const ImU8 *buffer, int size, Filter filter = Filter::Nearest, int width = 0, int height = 0); - Texture(std::span bytes, Filter filter = Filter::Nearest, int width = 0, int height = 0); - explicit Texture(const char *path, Filter filter = Filter::Nearest); - explicit Texture(const std::fs::path &path, Filter filter = Filter::Nearest); - Texture(unsigned int texture, int width, int height); Texture(const Texture&) = delete; Texture(Texture&& other) noexcept; + static Texture fromImage(const ImU8 *buffer, int size, Filter filter = Filter::Nearest); + static Texture fromImage(std::span buffer, Filter filter = Filter::Nearest); + static Texture fromImage(const char *path, Filter filter = Filter::Nearest); + static Texture fromImage(const std::fs::path &path, Filter filter = Filter::Nearest); + static Texture fromGLTexture(unsigned int texture, int width, int height); + static Texture fromBitmap(const ImU8 *buffer, int size, int width, int height, Filter filter = Filter::Nearest); + static Texture fromBitmap(std::span buffer, int width, int height, Filter filter = Filter::Nearest); + static Texture fromSVG(const char *path, int width = 0, int height = 0, Filter filter = Filter::Nearest); + static Texture fromSVG(const std::fs::path &path, int width = 0, int height = 0, Filter filter = Filter::Nearest); + static Texture fromSVG(std::span buffer, int width = 0, int height = 0, Filter filter = Filter::Nearest); + + ~Texture(); Texture& operator=(const Texture&) = delete; diff --git a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp index 6755dc632..5df39ac0d 100644 --- a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp +++ b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp @@ -12,10 +12,11 @@ #define STB_IMAGE_IMPLEMENTATION #include +#include + #include #include - #include #include @@ -40,74 +41,167 @@ namespace ImGuiExt { return GL_NEAREST; } + GLuint createTextureFromRGBA8Array(const ImU8 *buffer, int width, int height, Texture::Filter filter) { + GLuint texture; + + // Generate texture + glGenTextures(1, &texture); + glBindTexture(GL_TEXTURE_2D, texture); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, getGLFilter(filter)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, getGLFilter(filter)); + + #if defined(GL_UNPACK_ROW_LENGTH) + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + #endif + + // Allocate storage for the texture + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer); + + return texture; + } + + GLuint createMultisampleTextureFromRGBA8Array(const ImU8 *buffer, int width, int height, Texture::Filter filter) { + // Create a regular texture from the RGBA8 array + GLuint texture = createTextureFromRGBA8Array(buffer, width, height, filter); + + if (filter == Texture::Filter::Nearest) + return texture; + + constexpr static auto SampleCount = 8; + + // Generate renderbuffer + GLuint renderbuffer; + glGenRenderbuffers(1, &renderbuffer); + glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer); + glRenderbufferStorageMultisample(GL_RENDERBUFFER, SampleCount, GL_DEPTH24_STENCIL8, width, height); + + // Generate framebuffer + GLuint framebuffer; + glGenFramebuffers(1, &framebuffer); + glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); + + // Attach texture to color attachment 0 + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); + + // Attach renderbuffer to depth-stencil attachment + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, renderbuffer); + + // Check framebuffer status + if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { + return 0; + } + + // Unbind framebuffer + glBindFramebuffer(GL_FRAMEBUFFER, 0); + + return texture; + } + } - Texture::Texture(const ImU8 *buffer, int size, Filter filter, int width, int height) { + Texture Texture::fromImage(const ImU8 *buffer, int size, Filter filter) { if (size == 0) - return; + return {}; unsigned char *imageData = nullptr; - if (width == 0 || height == 0) - imageData = stbi_load_from_memory(buffer, size, &m_width, &m_height, nullptr, 4); - - if (imageData == nullptr) { - if (width * height * 4 > size) - return; - - imageData = static_cast(STBI_MALLOC(size)); - std::memcpy(imageData, buffer, size); - m_width = width; - m_height = height; - } + Texture result; + imageData = stbi_load_from_memory(buffer, size, &result.m_width, &result.m_height, nullptr, 4); if (imageData == nullptr) - return; + return {}; - GLuint texture; - glGenTextures(1, &texture); - glBindTexture(GL_TEXTURE_2D, texture); + GLuint texture = createMultisampleTextureFromRGBA8Array(imageData, result.m_width, result.m_height, filter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, getGLFilter(filter)); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, getGLFilter(filter)); - - #if defined(GL_UNPACK_ROW_LENGTH) - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - #endif - - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData); STBI_FREE(imageData); - m_textureId = reinterpret_cast(static_cast(texture)); + result.m_textureId = reinterpret_cast(static_cast(texture)); + + return result; } - Texture::Texture(std::span bytes, Filter filter, int width, int height) : Texture(reinterpret_cast(bytes.data()), bytes.size(), filter, width, height) { } + Texture Texture::fromImage(std::span buffer, Filter filter) { + return Texture::fromImage(reinterpret_cast(buffer.data()), buffer.size(), filter); + } - Texture::Texture(const std::fs::path &path, Filter filter) : Texture(reinterpret_cast(path.u8string().c_str()), filter) { } - Texture::Texture(const char *path, Filter filter) { - unsigned char *imageData = stbi_load(path, &m_width, &m_height, nullptr, 4); + Texture Texture::fromImage(const std::fs::path &path, Filter filter) { + return Texture::fromImage(wolv::util::toUTF8String(path).c_str(), filter); + } + + Texture Texture::fromImage(const char *path, Filter filter) { + Texture result; + unsigned char *imageData = stbi_load(path, &result.m_width, &result.m_height, nullptr, 4); if (imageData == nullptr) - return; + return {}; - GLuint texture; - glGenTextures(1, &texture); - glBindTexture(GL_TEXTURE_2D, texture); + GLuint texture = createMultisampleTextureFromRGBA8Array(imageData, result.m_width, result.m_height, filter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, getGLFilter(filter)); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, getGLFilter(filter)); - - #if defined(GL_UNPACK_ROW_LENGTH) - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - #endif - - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData); STBI_FREE(imageData); - m_textureId = reinterpret_cast(static_cast(texture)); + result.m_textureId = reinterpret_cast(static_cast(texture)); + + return result; } - Texture::Texture(unsigned int texture, int width, int height) : m_textureId(reinterpret_cast(static_cast(texture))), m_width(width), m_height(height) { + Texture Texture::fromGLTexture(unsigned int glTexture, int width, int height) { + Texture texture; + texture.m_textureId = reinterpret_cast(static_cast(glTexture)); + texture.m_width = width; + texture.m_height = height; + return texture; + } + + Texture Texture::fromBitmap(std::span buffer, int width, int height, Filter filter) { + return Texture::fromBitmap(reinterpret_cast(buffer.data()), buffer.size(), width, height, filter); + } + + Texture Texture::fromBitmap(const ImU8 *buffer, int size, int width, int height, Filter filter) { + if (width * height * 4 > size) + return {}; + + GLuint texture = createMultisampleTextureFromRGBA8Array(buffer, width, height, filter); + + Texture result; + result.m_width = width; + result.m_height = height; + result.m_textureId = reinterpret_cast(static_cast(texture)); + + return result; + } + + Texture Texture::fromSVG(const char *path, int width, int height, Filter filter) { + auto document = lunasvg::Document::loadFromFile(path); + auto bitmap = document->renderToBitmap(width, height); + + auto texture = createMultisampleTextureFromRGBA8Array(bitmap.data(), bitmap.width(), bitmap.height(), filter); + + Texture result; + result.m_width = bitmap.width(); + result.m_height = bitmap.height(); + result.m_textureId = reinterpret_cast(static_cast(texture)); + + return result; + } + + Texture Texture::fromSVG(const std::fs::path &path, int width, int height, Filter filter) { + return Texture::fromSVG(wolv::util::toUTF8String(path).c_str(), width, height, filter); + } + + Texture Texture::fromSVG(std::span buffer, int width, int height, Filter filter) { + auto document = lunasvg::Document::loadFromData(reinterpret_cast(buffer.data()), buffer.size()); + auto bitmap = document->renderToBitmap(width, height); + bitmap.convertToRGBA(); + + auto texture = createMultisampleTextureFromRGBA8Array(bitmap.data(), bitmap.width(), bitmap.height(), filter); + + Texture result; + result.m_width = bitmap.width(); + result.m_height = bitmap.height(); + result.m_textureId = reinterpret_cast(static_cast(texture)); + + return result; } Texture::Texture(Texture&& other) noexcept { diff --git a/lib/third_party/lunasvg b/lib/third_party/lunasvg new file mode 160000 index 000000000..17b595a6f --- /dev/null +++ b/lib/third_party/lunasvg @@ -0,0 +1 @@ +Subproject commit 17b595a6f1fa10ff5f56a7ab9a7134b511735968 diff --git a/main/gui/source/init/splash_window.cpp b/main/gui/source/init/splash_window.cpp index e84ba1114..217b7f51d 100644 --- a/main/gui/source/init/splash_window.cpp +++ b/main/gui/source/init/splash_window.cpp @@ -521,8 +521,8 @@ namespace hex::init { void WindowSplash::loadAssets() { // Load splash screen image from romfs - this->splashBackgroundTexture = ImGuiExt::Texture(romfs::get("splash_background.png").span(), ImGuiExt::Texture::Filter::Linear); - this->splashTextTexture = ImGuiExt::Texture(romfs::get("splash_text.png").span(), ImGuiExt::Texture::Filter::Linear); + this->splashBackgroundTexture = ImGuiExt::Texture::fromImage(romfs::get("splash_background.png").span(), ImGuiExt::Texture::Filter::Linear); + this->splashTextTexture = ImGuiExt::Texture::fromImage(romfs::get("splash_text.png").span(), ImGuiExt::Texture::Filter::Linear); // If the image couldn't be loaded correctly, something went wrong during the build process // Close the application since this would lead to errors later on anyway. diff --git a/plugins/builtin/include/content/helpers/diagrams.hpp b/plugins/builtin/include/content/helpers/diagrams.hpp index d66819565..58c47e065 100644 --- a/plugins/builtin/include/content/helpers/diagrams.hpp +++ b/plugins/builtin/include/content/helpers/diagrams.hpp @@ -129,7 +129,7 @@ namespace hex { pixel = ImAlphaBlendColors(pixel, ImColor(color)); } - m_texture = ImGuiExt::Texture(reinterpret_cast(pixels.data()), pixels.size() * 4, m_filter, 0xFF, 0xFF); + m_texture = ImGuiExt::Texture::fromBitmap(reinterpret_cast(pixels.data()), pixels.size() * 4, 0xFF, 0xFF, m_filter); m_textureValid = m_texture.isValid(); } } @@ -252,7 +252,7 @@ namespace hex { pixel = ImAlphaBlendColors(pixel, ImColor(color)); } - m_texture = ImGuiExt::Texture(reinterpret_cast(pixels.data()), pixels.size() * 4, m_filter, 0xFF, 0xFF); + m_texture = ImGuiExt::Texture::fromBitmap(reinterpret_cast(pixels.data()), pixels.size() * 4, 0xFF, 0xFF, m_filter); m_textureValid = m_texture.isValid(); } } diff --git a/plugins/builtin/romfs/assets/dark/banner.png b/plugins/builtin/romfs/assets/dark/banner.png deleted file mode 100644 index 262ffa89c..000000000 Binary files a/plugins/builtin/romfs/assets/dark/banner.png and /dev/null differ diff --git a/plugins/builtin/romfs/assets/dark/banner.svg b/plugins/builtin/romfs/assets/dark/banner.svg new file mode 100644 index 000000000..72c3c2992 --- /dev/null +++ b/plugins/builtin/romfs/assets/dark/banner.svg @@ -0,0 +1,226 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/builtin/romfs/assets/light/banner.png b/plugins/builtin/romfs/assets/light/banner.png deleted file mode 100644 index c91267440..000000000 Binary files a/plugins/builtin/romfs/assets/light/banner.png and /dev/null differ diff --git a/plugins/builtin/romfs/assets/light/banner.svg b/plugins/builtin/romfs/assets/light/banner.svg new file mode 100644 index 000000000..6f41e7545 --- /dev/null +++ b/plugins/builtin/romfs/assets/light/banner.svg @@ -0,0 +1,226 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/builtin/source/content/data_processor_nodes/other_nodes.cpp b/plugins/builtin/source/content/data_processor_nodes/other_nodes.cpp index c00401a29..cd522fde3 100644 --- a/plugins/builtin/source/content/data_processor_nodes/other_nodes.cpp +++ b/plugins/builtin/source/content/data_processor_nodes/other_nodes.cpp @@ -302,7 +302,7 @@ namespace hex::plugin::builtin { void process() override { const auto &rawData = this->getBufferOnInput(0); - m_texture = ImGuiExt::Texture(rawData.data(), rawData.size(), ImGuiExt::Texture::Filter::Nearest); + m_texture = ImGuiExt::Texture::fromImage(rawData.data(), rawData.size(), ImGuiExt::Texture::Filter::Nearest); } private: @@ -333,7 +333,7 @@ namespace hex::plugin::builtin { if (requiredBytes > rawData.size()) throwNodeError(hex::format("Image requires at least {} bytes of data, but only {} bytes are available", requiredBytes, rawData.size())); - m_texture = ImGuiExt::Texture(rawData.data(), rawData.size(), ImGuiExt::Texture::Filter::Nearest, width, height); + m_texture = ImGuiExt::Texture::fromBitmap(rawData.data(), rawData.size(), width, height, ImGuiExt::Texture::Filter::Nearest); } private: diff --git a/plugins/builtin/source/content/out_of_box_experience.cpp b/plugins/builtin/source/content/out_of_box_experience.cpp index d88ed1612..893b05a70 100644 --- a/plugins/builtin/source/content/out_of_box_experience.cpp +++ b/plugins/builtin/source/content/out_of_box_experience.cpp @@ -443,13 +443,13 @@ namespace hex::plugin::builtin { ImHexApi::System::setWindowResizable(false); const auto imageTheme = ThemeManager::getImageTheme(); - s_imhexBanner = ImGuiExt::Texture(romfs::get(hex::format("assets/{}/banner.png", imageTheme)).span()); - s_compassTexture = ImGuiExt::Texture(romfs::get("assets/common/compass.png").span()); - s_globeTexture = ImGuiExt::Texture(romfs::get("assets/common/globe.png").span()); + s_imhexBanner = ImGuiExt::Texture::fromImage(romfs::get(hex::format("assets/{}/banner.png", imageTheme)).span()); + s_compassTexture = ImGuiExt::Texture::fromImage(romfs::get("assets/common/compass.png").span()); + s_globeTexture = ImGuiExt::Texture::fromImage(romfs::get("assets/common/globe.png").span()); s_screenshotDescriptions = nlohmann::json::parse(romfs::get("assets/screenshot_descriptions.json").string()); for (const auto &path : romfs::list("assets/screenshots")) { - s_screenshots.emplace_back(path.filename(), ImGuiExt::Texture(romfs::get(path).span(), ImGuiExt::Texture::Filter::Linear)); + s_screenshots.emplace_back(path.filename(), ImGuiExt::Texture::fromImage(romfs::get(path).span(), ImGuiExt::Texture::Filter::Linear)); } s_drawEvent = EventFrameBegin::subscribe(drawOutOfBoxExperience); diff --git a/plugins/builtin/source/content/providers/process_memory_provider.cpp b/plugins/builtin/source/content/providers/process_memory_provider.cpp index a532181d2..d5d9efffd 100644 --- a/plugins/builtin/source/content/providers/process_memory_provider.cpp +++ b/plugins/builtin/source/content/providers/process_memory_provider.cpp @@ -165,7 +165,7 @@ namespace hex::plugin::builtin { for (auto &pixel : pixels) pixel = (pixel & 0xFF00FF00) | ((pixel & 0xFF) << 16) | ((pixel & 0xFF0000) >> 16); - texture = ImGuiExt::Texture(reinterpret_cast(pixels.data()), pixels.size(), ImGuiExt::Texture::Filter::Nearest, bitmap.bmWidth, bitmap.bmHeight); + texture = ImGuiExt::Texture::fromBitmap(reinterpret_cast(pixels.data()), pixels.size(), bitmap.bmWidth, bitmap.bmHeight, ImGuiExt::Texture::Filter::Nearest); } } } diff --git a/plugins/builtin/source/content/views/view_about.cpp b/plugins/builtin/source/content/views/view_about.cpp index 344209c57..e8aec2146 100644 --- a/plugins/builtin/source/content/views/view_about.cpp +++ b/plugins/builtin/source/content/views/view_about.cpp @@ -111,7 +111,7 @@ namespace hex::plugin::builtin { // Draw the ImHex icon if (!m_logoTexture.isValid()) - m_logoTexture = ImGuiExt::Texture(romfs::get("assets/common/logo.png").span(), ImGuiExt::Texture::Filter::Linear); + m_logoTexture = ImGuiExt::Texture::fromImage(romfs::get("assets/common/logo.png").span(), ImGuiExt::Texture::Filter::Linear); ImGui::Image(m_logoTexture, scaled({ 100, 100 })); if (ImGui::IsItemClicked()) { @@ -204,9 +204,9 @@ namespace hex::plugin::builtin { }; static std::array DonationPages = { - DonationPage { ImGuiExt::Texture(romfs::get("assets/common/donation/paypal.png").span(), ImGuiExt::Texture::Filter::Linear), "https://werwolv.net/donate" }, - DonationPage { ImGuiExt::Texture(romfs::get("assets/common/donation/github.png").span(), ImGuiExt::Texture::Filter::Linear), "https://github.com/sponsors/WerWolv" }, - DonationPage { ImGuiExt::Texture(romfs::get("assets/common/donation/patreon.png").span(), ImGuiExt::Texture::Filter::Linear), "https://patreon.com/werwolv" }, + DonationPage { ImGuiExt::Texture::fromImage(romfs::get("assets/common/donation/paypal.png").span(), ImGuiExt::Texture::Filter::Linear), "https://werwolv.net/donate" }, + DonationPage { ImGuiExt::Texture::fromImage(romfs::get("assets/common/donation/github.png").span(), ImGuiExt::Texture::Filter::Linear), "https://github.com/sponsors/WerWolv" }, + DonationPage { ImGuiExt::Texture::fromImage(romfs::get("assets/common/donation/patreon.png").span(), ImGuiExt::Texture::Filter::Linear), "https://patreon.com/werwolv" }, }; if (ImGui::BeginTable("DonationLinks", 5, ImGuiTableFlags_SizingStretchSame)) { diff --git a/plugins/builtin/source/content/welcome_screen.cpp b/plugins/builtin/source/content/welcome_screen.cpp index 1e8deed38..a0ab340ee 100644 --- a/plugins/builtin/source/content/welcome_screen.cpp +++ b/plugins/builtin/source/content/welcome_screen.cpp @@ -181,7 +181,7 @@ namespace hex::plugin::builtin { if (ImGui::BeginTable("Welcome Outer", 1, ImGuiTableFlags_None, ImGui::GetContentRegionAvail() - margin)) { ImGui::TableNextRow(); ImGui::TableNextColumn(); - ImGui::Image(s_bannerTexture, s_bannerTexture.getSize() / (3.5F * (1.0F / ImHexApi::System::getGlobalScale()))); + ImGui::Image(s_bannerTexture, s_bannerTexture.getSize()); ImGui::NewLine(); @@ -497,11 +497,15 @@ namespace hex::plugin::builtin { RequestChangeTheme::subscribe([](const std::string &theme) { auto changeTexture = [&](const std::string &path) { - return ImGuiExt::Texture(romfs::get(path).span(), ImGuiExt::Texture::Filter::Linear); + return ImGuiExt::Texture::fromImage(romfs::get(path).span(), ImGuiExt::Texture::Filter::Linear); + }; + + auto changeTextureSvg = [&](const std::string &path) { + return ImGuiExt::Texture::fromSVG(romfs::get(path).span(), 300_scaled, 0, ImGuiExt::Texture::Filter::Linear); }; ThemeManager::changeTheme(theme); - s_bannerTexture = changeTexture(hex::format("assets/{}/banner.png", ThemeManager::getImageTheme())); + s_bannerTexture = changeTextureSvg(hex::format("assets/{}/banner.svg", ThemeManager::getImageTheme())); s_backdropTexture = changeTexture(hex::format("assets/{}/backdrop.png", ThemeManager::getImageTheme())); if (!s_bannerTexture.isValid()) { @@ -617,7 +621,7 @@ namespace hex::plugin::builtin { for (const auto &defaultPath : fs::getDefaultPaths(fs::ImHexPath::Resources)) { const auto infoBannerPath = defaultPath / "info_banner.png"; if (wolv::io::fs::exists(infoBannerPath)) { - s_infoBannerTexture = ImGuiExt::Texture(wolv::util::toUTF8String(infoBannerPath).c_str(), ImGuiExt::Texture::Filter::Linear); + s_infoBannerTexture = ImGuiExt::Texture::fromImage(infoBannerPath, ImGuiExt::Texture::Filter::Linear); if (s_infoBannerTexture.isValid()) break; @@ -635,7 +639,7 @@ namespace hex::plugin::builtin { const auto &data = response.getData(); if (!data.empty()) { TaskManager::doLater([data] { - s_infoBannerTexture = ImGuiExt::Texture(data.data(), data.size(), ImGuiExt::Texture::Filter::Linear); + s_infoBannerTexture = ImGuiExt::Texture::fromImage(data.data(), data.size(), ImGuiExt::Texture::Filter::Linear); }); } } diff --git a/plugins/builtin/source/content/window_decoration.cpp b/plugins/builtin/source/content/window_decoration.cpp index 3461467b5..65e1a603d 100644 --- a/plugins/builtin/source/content/window_decoration.cpp +++ b/plugins/builtin/source/content/window_decoration.cpp @@ -389,7 +389,7 @@ namespace hex::plugin::builtin { void addWindowDecoration() { EventFrameBegin::subscribe([]{ AT_FIRST_TIME { - s_logoTexture = ImGuiExt::Texture(romfs::get("assets/common/icon.png").span(), ImGuiExt::Texture::Filter::Nearest); + s_logoTexture = ImGuiExt::Texture::fromImage(romfs::get("assets/common/icon.png").span(), ImGuiExt::Texture::Filter::Nearest); }; constexpr static ImGuiWindowFlags windowFlags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoNavFocus | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse; diff --git a/plugins/visualizers/source/content/pl_visualizers/3d_model.cpp b/plugins/visualizers/source/content/pl_visualizers/3d_model.cpp index 0d90fed8d..b0a495c8b 100644 --- a/plugins/visualizers/source/content/pl_visualizers/3d_model.cpp +++ b/plugins/visualizers/source/content/pl_visualizers/3d_model.cpp @@ -783,7 +783,7 @@ namespace hex::plugin::visualizers { vertexArray.bind(); if (s_shouldUpdateTexture) { s_shouldUpdateTexture = false; - s_modelTexture = ImGuiExt::Texture(s_texturePath, ImGuiExt::Texture::Filter::Nearest); + s_modelTexture = ImGuiExt::Texture::fromImage(s_texturePath, ImGuiExt::Texture::Filter::Nearest); } if (s_drawTexture) @@ -899,7 +899,7 @@ namespace hex::plugin::visualizers { vertexArray.unbind(); frameBuffer.unbind(); - s_texture = ImGuiExt::Texture(renderTexture.release(), GLsizei(renderTexture.getWidth()), GLsizei(renderTexture.getHeight())); + s_texture = ImGuiExt::Texture::fromGLTexture(renderTexture.release(), GLsizei(renderTexture.getWidth()), GLsizei(renderTexture.getHeight())); drawWindow(s_texture, s_renderingWindowSize, mvp); } diff --git a/plugins/visualizers/source/content/pl_visualizers/coordinates.cpp b/plugins/visualizers/source/content/pl_visualizers/coordinates.cpp index cf6034490..1dd2b4523 100644 --- a/plugins/visualizers/source/content/pl_visualizers/coordinates.cpp +++ b/plugins/visualizers/source/content/pl_visualizers/coordinates.cpp @@ -20,7 +20,7 @@ namespace hex::plugin::visualizers { static std::mutex addressMutex; static TaskHolder addressTask; - static auto mapTexture = ImGuiExt::Texture(romfs::get("assets/common/map.jpg").span(), ImGuiExt::Texture::Filter::Linear); + static auto mapTexture = ImGuiExt::Texture::fromImage(romfs::get("assets/common/map.jpg").span(), ImGuiExt::Texture::Filter::Linear); static ImVec2 mapSize = scaled(ImVec2(500, 500 / mapTexture.getAspectRatio())); if (shouldReset) { diff --git a/plugins/visualizers/source/content/pl_visualizers/image.cpp b/plugins/visualizers/source/content/pl_visualizers/image.cpp index 57e91bf24..8ebf38a58 100644 --- a/plugins/visualizers/source/content/pl_visualizers/image.cpp +++ b/plugins/visualizers/source/content/pl_visualizers/image.cpp @@ -16,7 +16,7 @@ namespace hex::plugin::visualizers { auto pattern = arguments[0].toPattern(); auto data = pattern->getBytes(); - texture = ImGuiExt::Texture(data.data(), data.size(), ImGuiExt::Texture::Filter::Nearest); + texture = ImGuiExt::Texture::fromImage(data.data(), data.size(), ImGuiExt::Texture::Filter::Nearest); scale = 200_scaled / texture.getSize().x; } @@ -42,7 +42,7 @@ namespace hex::plugin::visualizers { auto height = arguments[2].toUnsigned(); auto data = pattern->getBytes(); - texture = ImGuiExt::Texture(data.data(), data.size(), ImGuiExt::Texture::Filter::Nearest, width, height); + texture = ImGuiExt::Texture::fromBitmap(data.data(), data.size(), width, height, ImGuiExt::Texture::Filter::Nearest); } if (texture.isValid()) diff --git a/resources/dist/common/logo/ImHexLogoSVGBG.png b/resources/dist/common/logo/ImHexLogoSVGBG.png deleted file mode 100644 index 3b08e4ee1..000000000 Binary files a/resources/dist/common/logo/ImHexLogoSVGBG.png and /dev/null differ diff --git a/resources/dist/common/logo/ImHexLogoSVGBGShadows.png b/resources/dist/common/logo/ImHexLogoSVGBGShadows.png deleted file mode 100644 index 1d477d476..000000000 Binary files a/resources/dist/common/logo/ImHexLogoSVGBGShadows.png and /dev/null differ diff --git a/resources/dist/common/logo/ImHexLogoSVGFilled.png b/resources/dist/common/logo/ImHexLogoSVGFilled.png deleted file mode 100644 index c91267440..000000000 Binary files a/resources/dist/common/logo/ImHexLogoSVGFilled.png and /dev/null differ diff --git a/resources/dist/common/logo/ImHexLogoSVGFilledLight.svg b/resources/dist/common/logo/ImHexLogoSVGFilledLight.svg new file mode 100644 index 000000000..72c3c2992 --- /dev/null +++ b/resources/dist/common/logo/ImHexLogoSVGFilledLight.svg @@ -0,0 +1,226 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +