mirror of
https://github.com/ocornut/imgui.git
synced 2025-12-20 21:35:32 +00:00
DrawList, Fonts: fixed ImFontAtlasTextureRepack() overwriting draw list shared data UV's etc. even when not bound. (#8694, #8465)
ImFontAtlasUpdateDrawListsSharedData() call from ImFontAtlasTextureRepack() would trigger this. For simplicity we also track current atlas in ImDrawListSharedData, but we could probably use Font->ContainerAtlas.
This commit is contained in:
10
imgui.cpp
10
imgui.cpp
@@ -3932,7 +3932,7 @@ void ImGui::RenderMouseCursor(ImVec2 base_pos, float base_scale, ImGuiMouseCurso
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (mouse_cursor <= ImGuiMouseCursor_None || mouse_cursor >= ImGuiMouseCursor_COUNT) // We intentionally accept out of bound values.
|
||||
mouse_cursor = ImGuiMouseCursor_Arrow;
|
||||
ImFontAtlas* font_atlas = g.DrawListSharedData.Font->ContainerAtlas;
|
||||
ImFontAtlas* font_atlas = g.DrawListSharedData.FontAtlas;
|
||||
for (ImGuiViewportP* viewport : g.Viewports)
|
||||
{
|
||||
// We scale cursor with current viewport/monitor, however Windows 10 for its own hardware cursor seems to be using a different scale factor.
|
||||
@@ -8813,10 +8813,12 @@ void ImGui::SetCurrentFont(ImFont* font, float font_size_before_scaling, float f
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
IM_ASSERT(font->Scale > 0.0f);
|
||||
#endif
|
||||
g.DrawListSharedData.Font = g.Font;
|
||||
ImFontAtlasUpdateDrawListsSharedData(g.Font->ContainerAtlas);
|
||||
ImFontAtlas* atlas = font->ContainerAtlas;
|
||||
g.DrawListSharedData.FontAtlas = atlas;
|
||||
g.DrawListSharedData.Font = font;
|
||||
ImFontAtlasUpdateDrawListsSharedData(atlas);
|
||||
if (g.CurrentWindow != NULL)
|
||||
g.CurrentWindow->DrawList->_SetTexture(font->ContainerAtlas->TexRef);
|
||||
g.CurrentWindow->DrawList->_SetTexture(atlas->TexRef);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user