From 4d1ba782eef4ff774d671a0d3bb48d31aa5412c0 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 19 Mar 2026 11:54:42 +0100 Subject: [PATCH] Revert changing default value of ImTextureID_Invalid to -1. Back to 0. (#9295, #9310, #9293, #8745, #8465, #7090) Reverts 0db591935f08c73f1e0726869a92ca803e8660a9 --- docs/CHANGELOG.txt | 10 ---------- imgui.cpp | 4 ---- imgui.h | 10 +++++----- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index fcdcd08ba..9966d8519 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -41,16 +41,6 @@ HOW TO UPDATE? Breaking Changes: - - Changed default ImTextureID_Invalid value to -1 instead of 0 if not #define-d. - (#9293, #8745, #8465, #7090) - - It seems like a better default since it will work with backends storing - indices or memory offsets inside ImTextureID, where 0 might be a valid value. - - If this is causing problem with e.g your custom ImTextureID definition, you can - add '#define ImTextureID_Invalid 0' to your imconfig.h + PLEASE report this to GitHub. - - If you have hardcoded e.g. 'if (tex_id == 0)' checks they should be updated. - e.g. OpenGL2, OpenGL3 and SDLRenderer3 backends incorrectly had 'IM_ASSERT(tex->TexID == 0)' - lines which were replaced with 'IM_ASSERT(tex->TexID == ImTextureID_Invalid)'. - If you have copied or forked backends consider fixing locally. (#9295) - Separator(): fixed a legacy quirk where Separator() was submitting a zero-height item for layout purpose, even though it draws a 1-pixel separator. The fix could affect code e.g. computing height from multiple widgets in order to diff --git a/imgui.cpp b/imgui.cpp index 1478018a6..8de5a769d 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -395,10 +395,6 @@ IMPLEMENTING SUPPORT for ImGuiBackendFlags_RendererHasTextures: When you are not sure about an old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files. You can read releases logs https://github.com/ocornut/imgui/releases for more details. - - 2026/03/12 (1.92.7) - Changed default ImTextureID_Invalid to -1 instead of 0 if not #define-d. (#9293, #8745, #8465, #7090) - It seems like a better default since it will work with backends storing indices or memory offsets inside ImTextureID, where 0 might be a valid value. - If this is causing problem with e.g. your custom ImTextureID definition, you can add '#define ImTextureID_Invalid 0' to your imconfig.h + PLEASE report this to GitHub. - If you have hard-coded e.g. 'if (tex_id == 0)' checks they should be updated. e.g. OpenGL2, OpenGL3 and SDLRenderer3 backends incorrectly had 'IM_ASSERT(tex->TexID == 0)' lines which were replaced with 'IM_ASSERT(tex->TexID == ImTextureID_Invalid)'. (#9295) - 2026/02/26 (1.92.7) - Separator: fixed a legacy quirk where Separator() was submitting a zero-height item for layout purpose, even though it draws a 1-pixel separator. The fix could affect code e.g. computing height from multiple widgets in order to allocate vertical space for a footer or multi-line status bar. (#2657, #9263) The "Console" example had such a bug: diff --git a/imgui.h b/imgui.h index e4f4f5d8a..f0f7c7c80 100644 --- a/imgui.h +++ b/imgui.h @@ -341,10 +341,10 @@ typedef ImU64 ImTextureID; // Default: store up to 64-bits (any pointer or #endif // Define this if you need to change the invalid value for your backend. -// - in v1.92.7 (2025/03/12): we changed default value from 0 to -1 as it is a better default, which supports storing offsets/indices. -// - If this is causing problem with your custom ImTextureID definition, you can add '#define ImTextureID_Invalid' to your imconfig + please report this to GitHub. +// - If your backend is using ImTextureID to store an index/offset and you need 0 to be valid, You can add '#define ImTextureID_Invalid ((ImTextureID)-1)' in your imconfig.h file. +// - From 2026/03/12 to 2026/03/19 we experimented with changing to default to -1, but I worried it would cause too many issues in third-party code so it was reverted. #ifndef ImTextureID_Invalid -#define ImTextureID_Invalid ((ImTextureID)-1) +#define ImTextureID_Invalid ((ImTextureID)0) #endif // ImTextureRef = higher-level identifier for a texture. Store a ImTextureID _or_ a ImTextureData*. @@ -3909,8 +3909,8 @@ inline ImTextureID ImTextureRef::GetTexID() const // Using an indirection to avoid patching ImDrawCmd after a SetTexID() call (but this could be an alternative solution too) inline ImTextureID ImDrawCmd::GetTexID() const { - // If you are getting this assert with ImTextureID_Invalid == 0 and your ImTextureID is used to store an index: - // - You can add '#define ImTextureID_Invalid ((ImTextureID)-1)' in your imconfig file. + // If you are getting this assert with ImTextureID_Invalid == 0 and your ImTextureID is used to store an index or an offset: + // - You can add '#define ImTextureID_Invalid ((ImTextureID)-1)' in your imconfig.h file. // If you are getting this assert with a renderer backend with support for ImGuiBackendFlags_RendererHasTextures (1.92+): // - You must correctly iterate and handle ImTextureData requests stored in ImDrawData::Textures[]. See docs/BACKENDS.md. ImTextureID tex_id = TexRef._TexData ? TexRef._TexData->TexID : TexRef._TexID; // == TexRef.GetTexID() above.