Textures: Single Textures[] array allows backend to not have to care about atlases.

# Conflicts:
#	imgui.h
This commit is contained in:
ocornut
2025-01-31 19:12:58 +01:00
parent ee357aaddf
commit a21a2e855b
2 changed files with 25 additions and 5 deletions

View File

@@ -1271,6 +1271,7 @@ static void UpdateKeyRoutingTable(ImGuiKeyRoutingTable* rt);
// Misc
static void UpdateFontsNewFrame();
static void UpdateTexturesNewFrame();
static void UpdateTexturesEndFrame();
static void UpdateSettings();
static int UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_hovered, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4], const ImRect& visibility_rect);
static void RenderWindowOuterBorders(ImGuiWindow* window);
@@ -5182,6 +5183,18 @@ static void ImGui::UpdateTexturesNewFrame()
ImFontAtlasUpdateNewFrame(atlas);
}
// Build a single texture list
// We want to avoid user reading from atlas->TexList[] in order to facilitate better support for multiple atlases.
static void ImGui::UpdateTexturesEndFrame()
{
ImGuiContext& g = *GImGui;
ImFontAtlas* atlas = g.IO.Fonts;
g.PlatformIO.Textures.resize(0);
g.PlatformIO.Textures.reserve(atlas->TexList.Size);
for (ImTextureData* tex : atlas->TexList)
g.PlatformIO.Textures.push_back(tex);
}
// Called once a frame. Followed by SetCurrentFont() which sets up the remaining data.
// FIXME-VIEWPORT: the concept of a single ClipRectFullscreen is not ideal!
static void SetupDrawListSharedData()
@@ -5759,6 +5772,8 @@ void ImGui::EndFrame()
g.Windows.swap(g.WindowsTempSortBuffer);
g.IO.MetricsActiveWindows = g.WindowsActiveCount;
UpdateTexturesEndFrame();
// Unlock font atlas
g.IO.Fonts->Locked = false;