From 57a816ae609b09c384be938d4a1036483fe71f83 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 21 Jul 2025 15:27:17 +0900 Subject: [PATCH] Texutres: minor comments, tweaks. --- imgui_draw.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index f42f96639..5cb0ef8b5 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -2740,10 +2740,9 @@ void ImFontAtlasUpdateNewFrame(ImFontAtlas* atlas, int frame_count, bool rendere if (atlas->Builder == NULL) // This will only happen if fonts were not already loaded. ImFontAtlasBuildMain(atlas); } - else // Legacy backend - { + // Legacy backend + if (!atlas->RendererHasTextures) IM_ASSERT_USER_ERROR(atlas->TexIsBuilt, "Backend does not support ImGuiBackendFlags_RendererHasTextures, and font atlas is not built! Update backend OR make sure you called ImGui_ImplXXXX_NewFrame() function for renderer backend, which should call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8()."); - } if (atlas->TexIsBuilt && atlas->Builder->PreloadedAllGlyphsRanges) IM_ASSERT_USER_ERROR(atlas->RendererHasTextures == false, "Called ImFontAtlas::Build() before ImGuiBackendFlags_RendererHasTextures got set! With new backends: you don't need to call Build()."); @@ -2798,8 +2797,9 @@ void ImFontAtlasUpdateNewFrame(ImFontAtlas* atlas, int frame_count, bool rendere } else if (tex->WantDestroyNextFrame && tex->Status != ImTextureStatus_WantDestroy) { - // Request destroy. Keep bool as it allows us to keep track of things. - // We don't destroy pixels right away, as backend may have an in-flight copy from RAM. + // Request destroy. + // - Keep bool to true in order to differentiate a planned destroy vs a destroy decided by the backend. + // - We don't destroy pixels right away, as backend may have an in-flight copy from RAM. IM_ASSERT(tex->Status == ImTextureStatus_OK || tex->Status == ImTextureStatus_WantCreate || tex->Status == ImTextureStatus_WantUpdates); tex->Status = ImTextureStatus_WantDestroy; } @@ -2955,7 +2955,7 @@ void ImFontAtlasTextureBlockQueueUpload(ImFontAtlas* atlas, ImTextureData* tex, tex->UsedRect.h = (unsigned short)(ImMax(tex->UsedRect.y + tex->UsedRect.h, req.y + req.h) - tex->UsedRect.y); atlas->TexIsBuilt = false; - // No need to queue if status is _WantCreate + // No need to queue if status is == ImTextureStatus_WantCreate if (tex->Status == ImTextureStatus_OK || tex->Status == ImTextureStatus_WantUpdates) { tex->Status = ImTextureStatus_WantUpdates;