diff --git a/backends/imgui_impl_opengl3.cpp b/backends/imgui_impl_opengl3.cpp index 418a9a8f3..50b001a3e 100644 --- a/backends/imgui_impl_opengl3.cpp +++ b/backends/imgui_impl_opengl3.cpp @@ -676,7 +676,8 @@ void ImGui_ImplOpenGL3_UpdateTexture(ImTextureData* tex) // Backup GL_UNPACK state that we modify, restore on exit. GLint last_unpack_row_length = 0; (void)last_unpack_row_length; GLint last_unpack_alignment = 0; (void)last_unpack_alignment; - if (tex->Status == ImTextureStatus_WantCreate || tex->Status == ImTextureStatus_WantUpdates) + const bool last_unpack_state_save_and_restore = (tex->Status == ImTextureStatus_WantCreate || tex->Status == ImTextureStatus_WantUpdates); + if (last_unpack_state_save_and_restore) { #ifdef GL_UNPACK_ROW_LENGTH // Not on WebGL/ES GL_CALL(glGetIntegerv(GL_UNPACK_ROW_LENGTH, &last_unpack_row_length)); @@ -750,7 +751,7 @@ void ImGui_ImplOpenGL3_UpdateTexture(ImTextureData* tex) ImGui_ImplOpenGL3_DestroyTexture(tex); // Restore GL_UNPACK state - if (tex->Status == ImTextureStatus_WantCreate || tex->Status == ImTextureStatus_WantUpdates) + if (last_unpack_state_save_and_restore) { #ifdef GL_UNPACK_ROW_LENGTH GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, last_unpack_row_length)); diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 4bfa48d49..38f6b592f 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -47,7 +47,14 @@ Breaking Changes: of directly poking to io.ConfigColorEditFlags. More consistent and easier to discover. - Drag and Drop: commented out legacy name `ImGuiDragDropFlags_SourceAutoExpirePayload` which obsoleted in 1.90.9 (July 2024). Use `ImGuiDragDropFlags_PayloadAutoExpire`. - +- DragXXX, SliderXXX, InputScalar: with `ImGuiItemFlags_LiveEditOnInputScalar` now + defaulting to being disabled: inputting a value with the keyboard doesn't write + intermediate values to the backing variable. (#9476) + Before: DragFloat() with user typing "123" --> write back 1, then 12, then 123. + After: DragFloat() with user typing "123" --> write back 123 when validated/unfocused. + You can enable the flag back for a given scope if needed by specific widget/behavior. +- ImDrawData: marked `CmdListsCount` as obsolete (technically was obsoleted in 1.89.8). + Before: `draw_data->CmdListsCount`, After: `draw_data->CmdLists.Size`. Other Changes: @@ -63,9 +70,13 @@ Other Changes: - Added `ImGuiItemFlags_LiveEditOnInputText` and `ImGuiItemFlags_LiveEditOnInputScalar` flags to configure the timing of applying edits of backing variables when typing values using a keyboard. - (#701, #9476, #3936, #3946, #5904, #6284, #8149, #8065, #8665, #9117, #9299, #700, #1351, + (#9476, #701, #3936, #3946, #5904, #6284, #8149, #8065, #8665, #9117, #9299, #700, #1351, #1875, #2060, #2215, #2380, #2550, #3083, #3338, #3556, #4373, #4714, #4885, #5184, #5777, #6707, #6766, #8004, #8303, #8915, #9308) + - ImGuiItemFlags_LiveEditOnInputText is enabled by default (same as before): + - The expectation is that for strings/text, enabling LiveEdit is a better default. + - ImGuiItemFlags_LiveEditOnInputScalar is disabled by default (new behavior): + - The expectation is that for numeric/scalars values, disabling LiveEdit is a better default. - Until now: - Edits where always applied immediately to backing variable, which is equivalent to the `ImGuiItemFlags_LiveEditXXX` flags being enabled. @@ -76,28 +87,25 @@ Other Changes: Workarounds often required a backing store for scalar values, and there were also a few niggles related to `IsItemDeactivatedAfterEdit()` when using +/- buttons of an `InputInt()` widgets. - Many of those situations can now be naturally simplified by disabling - `ImGuiItemFlags_LiveEditOnInputScalar`, which is expected to become the default. + - Many of those situations can now be naturally simplified when disabling + `ImGuiItemFlags_LiveEditOnInputScalar` is disabled. - The new flags allows disabling this behavior selectively for strings fields such as `InputText()` vs scalar fields: `SliderInt()`, `InputFloat()`, etc. - When LiveEdit is disabled, edits are applied when pressing enter, tabbing out, clearing a field or deactivating due to a focus loss. - - The flag may be altered programmatically: - PushItemFlag(ImGuiItemFlags_LiveEditOnInputScalar, false); // Disable for scalars + - The flag may be altered programmatically, e.g. for the entire frame scope: + NewFrame(); + PushItemFlag(ImGuiItemFlags_LiveEditOnInputScalar, true); // Enable for scalars for the whole frame + .... + PopItemFlag(); + EndFrame(); + Or for a specific widget: + PushItemFlag(ImGuiItemFlags_LiveEditOnInput, true); // Enable for one widget SliderInt(...); PopItemFlag(); - PushItemFlag(ImGuiItemFlags_LiveEditOnInput, true); // Enable for all - SliderInt(...); - PopItemFlag(); - But with upcoming new defaults it is expected you shouldn't touch them much. - - Both flags currently defaults to true, which matches previous behavior. - - The expectation is that for strings/text, enabling LiveEdit is a better default. - - The expectation is that for scalars, disable LiveEdit is a better default. - - The short-term intent is to change `ImGuiItemFlags_LiveEditOnInputScalar` to - default to being disabled, as soon as we get more feedback from users (SOON). - We intentionally are not adding `io.ConfigLiveEditXXX` fields to dictate the - default value of each `ImGuiItemFlags_LiveEditXXX`, because this is not - expected to be a user preference but a programmer/widget preferences. + default value of each `ImGuiItemFlags_LiveEditXXX`, because this is not expected + to be a user preference but a programmer/widget preferences. Also, we strive to make the toolkit consistent. - InputText: - Added `style.InputTextCursorSize` to configure cursor/caret thickness. (#7031, #9409) @@ -3929,8 +3937,10 @@ Breaking changes: input queue. This is automatically cleared by io.ClearInputKeys(). (#4921) - ImDrawData: CmdLists[] array is now owned, changed from 'ImDrawList**' to 'ImVector'. Majority of users shouldn't be affected, but you - cannot compare to NULL nor reassign manually anymore. - Instead use AddDrawList(). Allocation count are identical. (#6406, #4879, #1878) + cannot compare to NULL nor reassign manually anymore. (#6406, #4879, #1878) + - Allocation count are identical. + - Use `draw_data->CmdLists.Size` instead of `draw_list->CmdListsCount`! + - Use `AddDrawList()` to add to a `ImDrawData`. Other changes: diff --git a/docs/FAQ.md b/docs/FAQ.md index f81fb8b02..e805566d8 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -25,7 +25,7 @@ or view this file with any Markdown viewer. | [I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around...](#q-i-integrated-dear-imgui-in-my-engine-and-some-elements-are-clipping-or-disappearing-when-i-move-windows-around) | | [I integrated Dear ImGui in my engine and some elements are displaying outside their expected windows boundaries...](#q-i-integrated-dear-imgui-in-my-engine-and-some-elements-are-displaying-outside-their-expected-windows-boundaries) | | **Q&A: Usage** | -| **[About the ID Stack system...](#q-about-the-id-stack-system)**
**[How can I have multiple widgets with the same label?](#q-how-can-i-have-multiple-widgets-with-the-same-label) (using `##` or `PushID()`)**
**[How can I have widgets with an empty label?](#q-how-can-i-have-widgets-with-an-empty-label) (using `##`)**
**[How can I animate the label of an existing widget?](#q-how-can-i-change-the-label-of-an-existing-widget) (using `###`)**
**[General description of the label and ID Stack system.](#general-description-of-the-label-and-id-stack-system)** | +| **[About the ID Stack system...](#q-about-the-id-stack-system)**
**[How can I have multiple widgets with the same label?](#q-how-can-i-have-multiple-widgets-with-the-same-label) (using `##` or `PushID()`)**
**[How can I have widgets with an empty label?](#q-how-can-i-have-widgets-with-an-empty-label) (using `##`)**
**[How can I make a label dynamic?](#q-how-can-i-make-a-label-dynamic) (using `###`)**
**[General description of the label and ID Stack system.](#general-description-of-the-label-and-id-stack-system)** | | [How can I display an image?](#q-how-can-i-display-an-image)
[What are ImTextureID/ImTextureRef?](#q-what-are-imtextureidimtextureref)| | [How can I use maths operators with ImVec2?](#q-how-can-i-use-maths-operators-with-imvec2) | | [How can I use my own maths types instead of ImVec2/ImVec4?](#q-how-can-i-use-my-own-maths-types-instead-of-imvec2imvec4) | @@ -85,16 +85,17 @@ Here's a very simplified comparison between the approach taken by Dear ImGui vs |--------------------------|--------------------------| | UI fully issued on every update. | UI issued once then later modified. | | UI layout is fully dynamic and can change at any time.
UI is generally emitted programmatically, which empowers reflecting a dynamic set of data. | UI layout is mostly static.
UI may be emitted programmatically or from data created by offline tools. UI need extra code to evolve, which is often tedious and error-prone if it needs to be reflecting dynamic data and systems. | -| Application can submit UI based on arbitrary logic and then forget about it. | Application needs more bookkeeping of UI elements. | +| UI system is optimized for the worst case and designed to be optimal even under frequent changes. | UI system is optimized for the case where nothing changes. Performances tends to degrade when anything changes. | +| Application can submit UI based on arbitrary logic without bookkeeping all aspects of that logic. | Application needs more bookkeeping of UI elements. | | UI library stores minimal amounts of data. At one point in time, it typically doesn't know or remember which other widgets are displayed and which widgets are coming next. As a result, certain layout features (alignment, resizing) are not as easy to implement or require ad-hoc code. | UI library stores entire widgets tree and state. UI library can use this retained data to easily layout things. | | UI code may be added anywhere.
You can even create UI to edit a local variable! | UI code needs to be added in dedicated spots. | | UI layout/logic/action/data bindings are all nearby in the code. | UI layout/logic/action/data bindings in distinct functions, files or formats. | | Data is naturally always synchronized. | Use callback/signal/slot for synchronizing data (error-prone). | -| API is simple and easy to learn. In particular, doing basic things is very easy. | API is more complex and specialized. | -| API is low-level (raw language types). | API are higher-level (more abstractions, advanced language features). | -| Less fancy look and feel. | Standard look and feel. | +| API is simple and easy to learn. In particular, doing basic things is very easy.
Attractive to more programmers. | API is more complex and specialized.
Tends to require specialized programmers. | +| API is low-level. Few abstractions, uses raw language types and your existing data. | API are higher-level. More abstractions, advanced language features. | +| Less fancy look and feel. But keeps improving :) | Standard look and feel. | | Compile yourself. Easy to debug, hack, modify, study. | Mostly use precompiled libraries. Compiling, modifying or studying is daunting if not impossible. | -| Run on every platform. | Run on limited desktop platforms. | +| Run on every platform (incl. web, consoles, mobiles, legacy systems). | Run on major desktop platforms. | Idiomatic Dear ImGui code: ```cpp diff --git a/imgui.cpp b/imgui.cpp index 6ced2858d..dd44f299f 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -402,6 +402,14 @@ IMPLEMENTING SUPPORT for ImGuiBackendFlags_RendererHasTextures: you may use GetMainViewport()->Pos to offset hard-coded positions, e.g. SetNextWindowPos(GetMainViewport()->Pos) - likewise io.MousePos and GetMousePos() will use OS coordinates. If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos. + - 2026/07/20 (1.92.9) - DragXXX, SliderXXX, InputScalar: with `ImGuiItemFlags_LiveEditOnInputScalar` now defaulting to being disabled: + inputting a value with the keyboard doesn't write intermediate values to backing variable. (#9476) + - Before: DragFloat() with user typing "123" --> write back 1, then 12, then 123. + - After: DragFloat() with user typing "123" --> write back 123 when validated/unfocused. + You can enable the flag back for a given scope if needed by specific widget/behavior. + - 2026/07/20 (1.92.9) - ImDrawData: marked ImDrawData::CmdListsCount as obsolete (technically was obsoleted in 1.89.8). + - Before: draw_data->CmdListsCount + - After: draw_data->CmdLists.Size - 2026/07/08 (1.92.9) - Drag and Drop: commented out legacy name `ImGuiDragDropFlags_SourceAutoExpirePayload` which obsoleted in 1.90.9 (July 2024). Use `ImGuiDragDropFlags_PayloadAutoExpire`. - 2026/07/06 (1.92.9) - ColorEdit: obsoleted SetColorEditOptions() function added in 1.51 (June 2017) in favor of directly poking to io.ConfigColorEditFlags. More consistent and easier to discover. - 2026/06/02 (1.92.9) - TreeNode: commented out legacy name ImGuiTreeNodeFlags_SpanTextWidth which was obsoleted in 1.90.7 (May 2024). Use ImGuiTreeNodeFlags_SpanLabelWidth instead. @@ -745,7 +753,9 @@ IMPLEMENTING SUPPORT for ImGuiBackendFlags_RendererHasTextures: - ImDrawCornerFlags_XXX -> use ImDrawFlags_RoundCornersXXX flags. Read 1.82 Changelog for details + grep commented names in sources. - commented out runtime support for hardcoded ~0 or 0x01..0x0F rounding flags values for AddRect()/AddRectFilled()/PathRect()/AddImageRounded() -> use ImDrawFlags_RoundCornersXXX flags. Read 1.82 Changelog for details - 2023/08/25 (1.89.9) - clipper: Renamed IncludeRangeByIndices() (also called ForceDisplayRangeByIndices() before 1.89.6) to IncludeItemsByIndex(). Kept inline redirection function. Sorry! - - 2023/07/12 (1.89.8) - ImDrawData: CmdLists now owned, changed from ImDrawList** to ImVector. Majority of users shouldn't be affected, but you cannot compare to NULL nor reassign manually anymore. Instead use AddDrawList(). (#6406, #4879, #1878) + - 2023/07/12 (1.89.8) - ImDrawData: CmdLists now owned, changed from ImDrawList** to ImVector. Majority of users shouldn't be affected, but you cannot compare to NULL nor reassign manually anymore. (#6406, #4879, #1878) + - use `draw_data->CmdLists.Size` instead of `draw_list->CmdListsCount`. + - use `draw_data->AddDrawList()` to add to a ImDrawData. - 2023/06/28 (1.89.7) - overlapping items: obsoleted 'SetItemAllowOverlap()' (called after item) in favor of calling 'SetNextItemAllowOverlap()' (called before item). 'SetItemAllowOverlap()' didn't and couldn't work reliably since 1.89 (2022-11-15). - 2023/06/28 (1.89.7) - overlapping items: renamed 'ImGuiTreeNodeFlags_AllowItemOverlap' to 'ImGuiTreeNodeFlags_AllowOverlap', 'ImGuiSelectableFlags_AllowItemOverlap' to 'ImGuiSelectableFlags_AllowOverlap'. Kept redirecting enums (will obsolete). - 2023/06/28 (1.89.7) - overlapping items: IsItemHovered() now by default return false when querying an item using AllowOverlap mode which is being overlapped. Use ImGuiHoveredFlags_AllowWhenOverlappedByItem to revert to old behavior. @@ -6145,7 +6155,7 @@ static void FlattenDrawDataIntoSingleLayer(ImDrawDataBuilder* builder) static void InitViewportDrawData(ImGuiViewportP* viewport) { - ImGuiIO& io = ImGui::GetIO(); + ImGuiContext& g = *GImGui; ImDrawData* draw_data = &viewport->DrawDataP; viewport->DrawData = draw_data; // Make publicly accessible @@ -6162,13 +6172,16 @@ static void InitViewportDrawData(ImGuiViewportP* viewport) const bool is_minimized = (viewport->Flags & ImGuiViewportFlags_IsMinimized) != 0; draw_data->Valid = true; - draw_data->CmdListsCount = 0; + draw_data->FrameCount = g.FrameCount; draw_data->TotalVtxCount = draw_data->TotalIdxCount = 0; draw_data->DisplayPos = viewport->Pos; draw_data->DisplaySize = is_minimized ? ImVec2(0.0f, 0.0f) : viewport->Size; - draw_data->FramebufferScale = (viewport->FramebufferScale.x != 0.0f) ? viewport->FramebufferScale : io.DisplayFramebufferScale; + draw_data->FramebufferScale = (viewport->FramebufferScale.x != 0.0f) ? viewport->FramebufferScale : g.IO.DisplayFramebufferScale; draw_data->OwnerViewport = viewport; - draw_data->Textures = &ImGui::GetPlatformIO().Textures; + draw_data->Textures = &g.PlatformIO.Textures; +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + draw_data->CmdListsCount = 0; +#endif } // Push a clipping rectangle for both ImGui logic (hit-testing etc.) and low-level ImDrawList rendering. @@ -6481,7 +6494,6 @@ void ImGui::Render() // We call _PopUnusedDrawCmd() last thing, as RenderDimmedBackgrounds() rely on a valid command being there (especially in docking branch). ImDrawData* draw_data = &viewport->DrawDataP; - IM_ASSERT(draw_data->CmdLists.Size == draw_data->CmdListsCount); for (ImDrawList* draw_list : draw_data->CmdLists) draw_list->_PopUnusedDrawCmd(); @@ -12198,7 +12210,7 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu *p_highlight = g.FrameCount; *p_alive = g.FrameCount; if (*p_highlight >= g.FrameCount - 1) - window->DrawList->AddRect(bb.Min - ImVec2(1, 1), bb.Max + ImVec2(1, 1), IM_COL32(255, 0, 0, 255), 0.0f, ImDrawFlags_None, 2.0f); + window->DrawList->AddRect(bb.Min - ImVec2(1, 1), bb.Max + ImVec2(1, 1), IM_COL32(255, 0, 0, 255), 0.0f, 2.0f); } #endif } diff --git a/imgui.h b/imgui.h index 8be565163..ae2913a2b 100644 --- a/imgui.h +++ b/imgui.h @@ -30,7 +30,7 @@ // Library Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345') #define IMGUI_VERSION "1.92.9 WIP" -#define IMGUI_VERSION_NUM 19286 +#define IMGUI_VERSION_NUM 19287 #define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000 #define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198 #define IMGUI_HAS_VIEWPORT // In 'docking' WIP branch. @@ -1295,18 +1295,16 @@ enum ImGuiItemFlags_ ImGuiItemFlags_Disabled = 1 << 6, // false // [Internal] Disable interactions. DOES NOT affect visuals. This is used by BeginDisabled()/EndDisabled() and only provided here so you can read back via GetItemFlags(). //--------------------------------------------------------------------------------- - // LiveEdit refers to applying edits to backing variables _while_ typing. + // LiveEdit refers to applying edits to backing variables _while_ typing a value using the keyboard. // Widget: | Input: | w/ LiveEdit: | Output: // InputText() | "123" | on(default) | "1" then "12" then "123" // InputText() | "123" | off | "123" after validating or tabbing out or losing focus. - // DragFloat(), SliderInt(), etc. | "123" | on(default)* | 1 then 12 then 123 - // DragFloat(), SliderInt(), etc. | "123" | off* | 123 after validation or tabbing out or losing focus. - //--------------------------------------------------------------------------------- - // (*) The feature is currently being evaluated, and the aim is to change ImGuiItemFlags_LiveEditOnInputScalar to OFF by default. - // The legacy behavior until July 2026 was that LiveEdit was always ON for everything. + // DragFloat(), SliderInt(), etc. | "123" | on* | 1 then 12 then 123 + // DragFloat(), SliderInt(), etc. | "123" | off(default)* | 123 after validation or tabbing out or losing focus. + // (*) Since 1.92.9 (July 2026), ImGuiItemFlags_LiveEditOnInputScalar is OFF by default. In prior version it was ON for everything. //--------------------------------------------------------------------------------- ImGuiItemFlags_LiveEditOnInputText = 1 << 7, // true // InputText: apply keyboard edits to backing value while typing. Otherwise, edits are applied when validating, tabbing out or losing focus. - ImGuiItemFlags_LiveEditOnInputScalar = 1 << 8, // true* // DragXXX, SliderXXX, InputScalar: apply keyboard edits to backing value while typing. Otherwise, edits are applied when validating, tabbing out or losing focus. + ImGuiItemFlags_LiveEditOnInputScalar = 1 << 8, // false // DragXXX, SliderXXX, InputScalar: apply keyboard edits to backing value while typing. Otherwise, edits are applied when validating, tabbing out or losing focus. ImGuiItemFlags_LiveEditOnInput = ImGuiItemFlags_LiveEditOnInputText | ImGuiItemFlags_LiveEditOnInputScalar, }; @@ -3629,7 +3627,7 @@ struct ImDrawList struct ImDrawData { bool Valid; // Only valid after Render() is called and before the next NewFrame() is called. - int CmdListsCount; // == CmdLists.Size. (OBSOLETE: exists for legacy reasons). Number of ImDrawList* to render. + int FrameCount; // Frame counter of the emitter context. For debugging purpose. int TotalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size int TotalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size ImVector CmdLists; // Array of ImDrawList* to render. The ImDrawLists are owned by ImGuiContext and only pointed to from here. @@ -3639,6 +3637,10 @@ struct ImDrawData ImGuiViewport* OwnerViewport; // Viewport carrying the ImDrawData instance, might be of use to the renderer (generally not). ImVector* Textures; // List of textures to update. Most of the times the list is shared by all ImDrawData, has only 1 texture and it doesn't need any update. This almost always points to ImGui::GetPlatformIO().Textures[]. May be overridden or set to NULL if you want to manually update textures. +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + int CmdListsCount; // Use CmdLists.Size instead. Number of ImDrawList* to render. +#endif + // Functions ImDrawData() { Clear(); } IMGUI_API void Clear(); @@ -3690,13 +3692,14 @@ struct ImTextureRect // Why does we store two identifiers: TexID and BackendUserData? // - ImTextureID TexID = lower-level identifier stored in ImDrawCmd. ImDrawCmd can refer to textures not created by the backend, and for which there's no ImTextureData. // - void* BackendUserData = higher-level opaque storage for backend own book-keeping. Some backends may have enough with TexID and not need both. - // In columns below: who reads/writes each fields? 'r'=read, 'w'=write, 'core'=main library, 'backend'=renderer backend +// In columns below: who reads/writes each fields? 'r'=read, 'w'=write, 'core'=main library, 'backend'=renderer backend struct ImTextureData { //------------------------------------------ core / backend --------------------------------------- int UniqueID; // w - // [DEBUG] Sequential index to facilitate identifying a texture when debugging/printing. Unique per atlas. ImTextureStatus Status; // rw rw // ImTextureStatus_OK/_WantCreate/_WantUpdates/_WantDestroy. Always use SetStatus() to modify! void* BackendUserData; // - rw // Convenience storage for backend. Some backends may have enough with TexID. + void* QueueUserData; // r - // Convenience storage for a staged/multi-threaded rendering texture queue (e.g. imgui_threaded_rendering.h. See #8597). When != NULL, core assumes the texture is referenced by the queue. ImTextureID TexID; // r w // Backend-specific texture identifier. Always use SetTexID() to modify! The identifier will stored in ImDrawCmd::GetTexID() and passed to backend's RenderDrawData function. ImTextureFormat Format; // w r // ImTextureFormat_RGBA32 (default) or ImTextureFormat_Alpha8 int Width; // w r // Texture width diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 4dc5f90ad..a6400e274 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -2286,11 +2286,14 @@ void ImDrawListSplitter::SetCurrentChannel(ImDrawList* draw_list, int idx) void ImDrawData::Clear() { Valid = false; - CmdListsCount = TotalIdxCount = TotalVtxCount = 0; + TotalIdxCount = TotalVtxCount = 0; CmdLists.resize(0); // The ImDrawList are NOT owned by ImDrawData but e.g. by ImGuiContext, so we don't clear them. DisplayPos = DisplaySize = FramebufferScale = ImVec2(0.0f, 0.0f); OwnerViewport = NULL; Textures = NULL; +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + CmdListsCount = 0; +#endif } // Important: 'out_list' is generally going to be draw_data->CmdLists, but may be another temporary list @@ -2335,16 +2338,17 @@ void ImGui::AddDrawListToDrawDataEx(ImDrawData* draw_data, ImVector // Add to output list + records state in ImDrawData out_list->push_back(draw_list); - draw_data->CmdListsCount++; draw_data->TotalVtxCount += draw_list->VtxBuffer.Size; draw_data->TotalIdxCount += draw_list->IdxBuffer.Size; } void ImDrawData::AddDrawList(ImDrawList* draw_list) { - IM_ASSERT(CmdLists.Size == CmdListsCount); draw_list->_PopUnusedDrawCmd(); ImGui::AddDrawListToDrawDataEx(this, &CmdLists, draw_list); +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + CmdListsCount = CmdLists.Size; +#endif } // For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering! @@ -2868,13 +2872,14 @@ bool ImTextureDataUpdateNewFrame(ImTextureData* tex) // If a texture has never reached the backend, they don't need to know about it. // (note: backends between 1.92.0 and 1.92.4 could set an already destroyed texture to ImTextureStatus_WantDestroy // when invalidating graphics objects twice, which would previously remove it from the list and crash.) - if (tex->Status == ImTextureStatus_WantDestroy && tex->TexID == ImTextureID_Invalid && tex->BackendUserData == NULL) + if (tex->Status == ImTextureStatus_WantDestroy && tex->TexID == ImTextureID_Invalid && tex->BackendUserData == NULL && tex->QueueUserData == NULL) tex->Status = ImTextureStatus_Destroyed; // Process texture being destroyed if (tex->Status == ImTextureStatus_Destroyed) { IM_ASSERT(tex->TexID == ImTextureID_Invalid && tex->BackendUserData == NULL && "Backend set texture Status to Destroyed but did not clear TexID/BackendUserData!"); + IM_ASSERT(tex->QueueUserData == NULL && "Texture queue set Status to Destroyed but did not clear QueueUserData!"); if (tex->WantDestroyNextFrame) remove_from_list = true; // Destroy was scheduled by us else diff --git a/imgui_internal.h b/imgui_internal.h index fedcac6a5..92145f8c7 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1017,7 +1017,7 @@ enum ImGuiItemFlagsPrivate_ ImGuiItemFlags_HasSelectionUserData = 1 << 21, // false // Set by SetNextItemSelectionUserData() ImGuiItemFlags_IsMultiSelect = 1 << 22, // false // Set by SetNextItemSelectionUserData() - ImGuiItemFlags_Default_ = ImGuiItemFlags_AutoClosePopups | ImGuiItemFlags_LiveEditOnInputText | ImGuiItemFlags_LiveEditOnInputScalar, // Please don't change, use PushItemFlag() instead. + ImGuiItemFlags_Default_ = ImGuiItemFlags_AutoClosePopups | ImGuiItemFlags_LiveEditOnInputText, // Please don't change, use PushItemFlag() instead. // Obsolete //ImGuiItemFlags_SelectableDontClosePopup = !ImGuiItemFlags_AutoClosePopups, // Can't have a redirect as we inverted the behavior