Stop using obsolete ImGui functions and enums - #2412
Open
totalgee wants to merge 2 commits into
Open
Conversation
- enable IMGUI_DISABLE_OBSOLETE_FUNCTIONS in imconfig.h and port the deprecated uses: tab/nav colour enums, the NavNoCaptureKeyboard flag, clipboard callbacks, Image() to ImageWithBg(), and DX12 legacy SRV descriptors. - make an inline version of Initialize() so IMGUI_CHECKVERSION() runs in the caller's translation unit, where it can catch an app/library config mismatch instead of only comparing the Cinder lib version to itself. - to resolve issue cinder#2411.
Contributor
Author
|
Verified against samples/D3d12ImageBasic: the allocator and free callbacks are exercised for ImGui's font atlas and the UI renders correctly. The multi-descriptor path (more than one texture live at once in DX12) is not exercised by any existing sample. |
- removed IgnoreSpecificDefaultLibraries (LIBCMT;LIBCPMT) from samples/ImGui, which broke its Release x64 link (/MT requests exactly the libs being ignored, so the CRT was excluded with thousands of unresolved symbols). - the same line appears in 67 sample projects; fixing the others seems out of scope here but is probably worth a separate pass.
Contributor
Author
|
Fixed broken Release build for
|
Contributor
Author
|
One last comment -- the most important part of this fix is the protection provided by doing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Breaking change -- needs a maintainer decision
Enabling
IMGUI_DISABLE_OBSOLETE_FUNCTIONSaffects downstream apps, not just Cinder. The most likely thing people hit is renamed colour enums, since many people might customizestyle.Colors[]:ImGuiCol_TabActiveImGuiCol_TabSelectedImGuiCol_TabUnfocusedImGuiCol_TabDimmedImGuiCol_TabUnfocusedActiveImGuiCol_TabDimmedSelectedImGuiCol_NavHighlightImGuiCol_NavCursorImGuiChildFlags_BorderImGuiChildFlags_BordersImGuiTreeNodeFlags_AllowItemOverlap...AllowOverlapplus a handful of functions (
SetWindowFontScale(),GetContentRegionMax(),SetItemAllowOverlap(), the oldCombo()/ListBox()callback form) and theio.FontGlobalScale/io.*ClipboardTextFnmembers.The blast radius is bounded: everything obsoleted before ~1.89 is already fully commented out in 1.92, so it is unavailable with or without this macro change! Only the dozen or so items still live in the obsolete section are affected here.
If that's too disruptive, the macro is a single line in
imconfig.hand I'm happy to comment it out -- the internal migration stands on its own, since these APIs will be deleted upstream eventually.Initialize()/InitializeImpl()splitIMGUI_CHECKVERSION()only detects a config mismatch when it is compiled in the caller's translation unit. The existing call inCinderImGui.cppcompares Cinder against itself and can never fail, which is why #2411 went undiagnosed. MakingInitialize()an inline header wrapper is the smallest way to get the check instantiated in application code with no change to how apps call it.Worth flagging: this moves the exported symbol from
InitializetoInitializeImpl, so it is an ABI change for anyone linking a prebuiltcinder.lib. Rebuilding resolves it. If you'd prefer a different shape (a separateImGui::CheckVersion()helper apps call themselves, or a differently named impl function), I could adjust it.One migration that is not a simple rename
Image()→ImageWithBg()is the only case where the compiler won't catch you: the old signature took(tint_col, border_col), the new one takes(bg_col, tint_col). Forwarding positionally compiles cleanly and renders incorrectly -- I hit that before spotting it.Cinder's public
ImGui::Image( Texture2dRef, size, uv0, uv1, tint, border )signature is unchanged, andborder_colis still honoured viaImGuiCol_BorderplusImGuiStyleVar_ImageBorderSize, mirroring ImGui's own obsolete shim inimgui_widgets.cpp(including forcing a minimum thickness when the colour has alpha, so a border still appears purely because a colour was supplied). However, the Cinder version of ImGui::Image() still takes the same arguments and order as before, so anyone using that (such assamples/ImGuiwill continue to work as before).DX12 is untested
I wrote the SRV descriptor allocator without a DX12 setup to run it on. That said, the previous code could not have worked here regardless: the
LegacySingleSrv*fields don't exist in 1.92, and the backend now allocates one descriptor per texture rather than one in total. I replaced them with the documentedSrvDescriptorAllocFn/SrvDescriptorFreeFncallbacks over a simple free list on the existing heap, following the pattern in ImGui'sexample_win32_directx12.It compiles, but someone with a D3D12 project (
samples/D3d12ImageBasicwould be the obvious test) should confirm it before this is relied on.How I verified
samples/ImGuibuilds and runs; verified interactively that the Tint Color and Border Color controls both affect the image as before.samples/,src/cinder/,include/cinder/andblocks/for remaining deprecated identifiers -- none found.