pkdawson / imgui-godot

Dear ImGui plugin for Godot 4
MIT License
423 stars 24 forks source link

How to Render ImGui in a New Window Instead of the Main Program Window? #53

Closed GenesisAN closed 4 months ago

GenesisAN commented 5 months ago

I am currently working on an application that involves multiple windows: a main program window and a newly created secondary window. My issue is that ImGui seems to render its content in the main window by default. I'm looking to have ImGui content rendered in the secondary window instead.

Unfortunately, I'm not fully familiar with the rendering process of ImGui and how it decides the target window for rendering. My apologies for reaching out without a deep understanding of the system's internals – I haven't had the chance to delve into the implementation details of ImGui's window handling.

Could someone guide me on how to direct ImGui to render in a specific window that is not the main program window? Any insights or references to documentation/examples that explain how ImGui interacts with multiple window contexts would be greatly appreciated.

pkdawson commented 5 months ago

This isn't a direct answer, but have you tried using Multi-Viewports? Just enable the config flag. You won't be able to snap the ImGui windows into your second window, but they can float freely.

Dear ImGui only supports one main window. I'll see if I can add a feature which lets you change that.

GenesisAN commented 5 months ago

wow,As a compromise it works, thank you very much. Of course I'd appreciate it if you could add support for multiple windows, hopefully this won't cause too much coding difficulty. I'll take a closer look at how it's implemented sometime.

pkdawson commented 4 months ago

Implemented ImGuiGD.SetMainViewport() in v5.1.0

https://github.com/pkdawson/imgui-godot/blob/a9217944e6e660084ebf32b702d2f6301b299c9a/src/MyNode.cs#L44-L53