From 7d7bf993bb0c37c9eadb22de456ea6be021451f8 Mon Sep 17 00:00:00 2001 From: cfillion Date: Tue, 22 Mar 2022 20:24:38 -0400 Subject: [PATCH] ImDrawList: Fix texture-based anti-aliasing with RGBA textures (#5132, #3245) When using an Alpha8 font texture, GetTexDataAsRGBA32 converts 0x00 to transparent white. When using a RGBA32 font texture, ImFontAtlasBuildRenderLinesTexData was writing transparent black. --- docs/CHANGELOG.txt | 1 + imgui_draw.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index c6228fbc..1b95abc0 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -61,6 +61,7 @@ Other Changes: - ColorEdit: Fixed text baseline alignment after a SameLine() after a ColorEdit() with visible label. - Stack Tool: Added option to copy item path to clipboard. (#4631) - Drawlist: Fixed PathArcTo() emitting terminating vertices too close to arc vertices. (#4993) [@thedmd] +- DrawList: Fixed texture-based anti-aliasing path with RGBA textures (#5132, #3245) [@cfillion] - Misc: Fixed IsAnyItemHovered() returning false when using navigation. - Misc: Added IMGUI_STB_SPRINTF_FILENAME to support custom path to stb_sprintf. (#5068, #2954) [@jakubtomsu] - Misc: Added constexpr to ImVec2/ImVec4 inline constructors. (#4995) [@Myriachan] diff --git a/imgui_draw.cpp b/imgui_draw.cpp index e9197586..3fbe99bf 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -2738,13 +2738,13 @@ static void ImFontAtlasBuildRenderLinesTexData(ImFontAtlas* atlas) { unsigned int* write_ptr = &atlas->TexPixelsRGBA32[r->X + ((r->Y + y) * atlas->TexWidth)]; for (unsigned int i = 0; i < pad_left; i++) - *(write_ptr + i) = IM_COL32_BLACK_TRANS; + *(write_ptr + i) = IM_COL32(255, 255, 255, 0); for (unsigned int i = 0; i < line_width; i++) *(write_ptr + pad_left + i) = IM_COL32_WHITE; for (unsigned int i = 0; i < pad_right; i++) - *(write_ptr + pad_left + line_width + i) = IM_COL32_BLACK_TRANS; + *(write_ptr + pad_left + line_width + i) = IM_COL32(255, 255, 255, 0); } // Calculate UVs for this line