Imgui: Multiple main viewports / or no main viewport

Created on 13 Jul 2020  路  3Comments  路  Source: ocornut/imgui

Version/Branch of Dear ImGui:

Version: WP 177
Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_opengl3.cpp + imgui_impl_morgoth.cpp (custom implementation forked from sdl)
Compiler: Visual Studio 2019
Operating System: Windows 10 Professional

My Issue/Question:
My engine start in headless mode and support multiple windows but the imgui main window paradigm dont allow me to dock or move windows into the other engine windows.

At the moment I'have a patched version that seem to work, I've tried to manually call AddUpdateViewport function and the system works fine but there are some other changes to be done like:

  • some checks on the PlatformWindowCreated bool to not exclude the viewports from processing
  • exclusion from UpdatePlatformWindows:
    in my case with
    if (is_new_platform_window && viewport->PlatformHandle != NULL)
    but probably there is a better way to achieve that
  • some asserts on non main viewports
  • introduction of a defaultViewport in the context with correlate Set/Get methods to allow to render elements like main menu bars on a specific window

I'know the standard use case is with a single main window but I think this feature will not exclude a main window paradigma, is more like an additional support for viewports with a NULL ImGuiWindow and a set of function the user can call (AddUpdateViewport, SetDefaultViewport, GetDefaultViewport)

multi-viewports

Most helpful comment

All 3 comments

Hello @morgoth990,

This has been discussed before and I like to support this mode of operation. I would be interested to see your changes (e.g. in the form of a repo or PR) for references. Likely won't be merged as-is but any extra reference will be useful. Someone actually submitted to me a codebase with similar change a year ago but it was made hastily with no git commits nor explanations for many changes and got essentially half lost :/

Two things come to mind:

  • Reliance on GetMainViewport() will need to be reworked. Perhaps we need to rework/blur the lines between Viewport and Monitors in order to provide an abstraction that works with both use case. e.g. being able to retrieve a reference "default" origin.
  • Some code assume that viewports[0] has the ImGuiViewportFlags_CanHostOtherWindows flag, and the use of that flag is probably a little ambiguous in some areas, may set to split the flag into multiple ones.

(Also, while technically completely unrelated, supporting this mode of operation will get us in territories where features such as #2749 will be highly desirable!)

Thanks for the details and comments. Not sure when we'll be able to look into it but this is going to be a good reference.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mnemode2 picture mnemode2  路  3Comments

ghost picture ghost  路  3Comments

namuda picture namuda  路  3Comments

dowit picture dowit  路  3Comments

GrammarLord picture GrammarLord  路  3Comments