Multi Viewports (original) (raw)

MultiViewports

What is it?

Multi-viewports is the feature allowing you to seamlessly extract Dear ImGui windows out of your main rendering context. In traditional game programming, your engine/game generally create an OS window associated to a graphics context (e.g. using DirectX, OpenGL) and all rendering has to happen inside this graphics context.

With multi-viewports, Dear ImGui gets the ability to create new OS windows and graphics contexts, as required to host Dear ImGui that have been moved outside the boundaries of the primary OS window. This is achieved via a set of flags and functions (inside ImGuiPlatformIO structure) which allows Dear ImGui to communicate with individual back-ends. Most back-ends provided in the backends/ folder can support multi-viewports.

Among other things, Multi-viewports also facilitate the use of Dear ImGui over multiple monitors.

Where to find it?

Multi-viewports are currently available in the docking branch. This is a well maintained branch and most large teams have been using this branch for a while. It is safe and recommended to use that branch.

How can I enable Multi-viewports ?

If you are using platform and renderer back-ends from the backends/ folder, they already support multi-viewports.

io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;

// Update and Render additional Platform Windows if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { ImGui::UpdatePlatformWindows(); ImGui::RenderPlatformWindowsDefault(); // TODO for OpenGL: restore current GL context. }

That's pretty much it. There may be additional calls required surrounding this depending on the backend you are using: OpenGL in particular needs backup/restore of current GL context. Check the example project appropriate to your setup for details.

There are a few additional multi-viewports related configuration flags in the IO structure which you may toy with.

If you are using a custom back-end, refer to the ImGuiPlatformIO structure and existing backends/ + examples/ to implement support for multi-viewports in your engine. This is not particularly easy to add.

Issues

FAQ