-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reorganization of context/allocators: CreateContext(), DestroyContext(), SetAllocatorFunctions() #1565
Comments
- YOU NOW NEED TO CALL ImGui::CreateContext() AT THE BEGINNING OF YOUR APP, AND CALL ImGui::DestroyContext() AT THE END. - removed Shutdown() function, as DestroyContext() serve this purpose. - you may pass a ImFontAtlas* pointer to CreateContext() to share a font atlas between contexts. Otherwhise CreateContext() will create its own font atlas instance. - removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions(), and shared by all contexts. - removed the default global context and font atlas instance, which were confusing for users of DLL reloading and users of multiple contexts (#1565, #586, #992, #1007, #1558)
…ve context yet, to be more flexible with creation order. (#1565)
I love it. |
Hi there, thanks for the update ! I just pulled and tested your changes and it worked fine to me. I tested with a single shared font right now and the instance was not loaded from a dynamic library. About break the existing codebase:It didn't change much to me, I just removed the Get/Set of default context which was useless to my use case, removed the |
Coincidentally this weekend I was working around a shutdown crash due to the global font atlas getting destructed after a context was disposed. This mod is most welcome. |
This looks a very nice addition! Thanks @ocornut ! |
Works here. Coalescing context shutdown is welcomed. I've made the goof twice of using |
Works great for us, a welcome improvement, thanks! |
I did similar thing this weekend before I noticed this thread. :) I tried the official code from the branch and it works great. Good job! |
This is now merged, I've also merged the Navigation branch and bumped versions to 1.60. I've added asserts to make this more visible:
|
I am reorganizing context management functions to be more explicit.
I have created a branch "context" to test those changes, and would very much like feedback on them!
https://github.com/ocornut/imgui/tree/context
The purpose of those changes is:
Those topics are discussed in e.g. #586, #992, #1007, #1558
Those changes DO NOT address multi-threading issues from #586.
Also note that the incoming virtual viewport feature (#1542) will allow you to manage multiple OS windows with a single context, therefore multiple context will become less useful and less exercised onward :) but we should still support them.
ImGui::CreateContext()
AT THE BEGINNING OF YOUR APP, AND CALLImGui::DestroyContext()
AT THE END.Shutdown()
function, asDestroyContext()
serve this purpose.CreateContext()
to share a font atlas between contexts. OtherwiseCreateContext()
will create its own font atlas instance and destroy it onDestroyContext()
.CreateContext()
, they are now setup withSetAllocatorFunctions()
, and shared by all contexts. Added avoid* user_data
to allocators function.IMGUI_DISABLE_DEFAULT_ALLOCATORS
imconfig.h directive for people who don't want to link with malloc/free at all.Those changes are touchy because it will break existing codebase:
I think I should push those change to master as they are for the better but would really like feedback from anyone using multiple contexts, multiple font atlas or DLL reloading. If you could quickly try to merge the
context
branch, see if it works for you. Any feedback on the changes are welcome..Tagging people involved or who may be interested in this.. Sorry for the tag-spam.
@aiekick @sonoro1234 @zx64 @thedmd @zlnimda @Pagghiu @itamago @galloman @matteomandelli @pdoane-blizzard
Thank you!
The text was updated successfully, but these errors were encountered: