ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
59.31k stars 10.11k forks source link

Transparent windows in a secondary viewport #7788

Open fsfuzhu opened 1 month ago

fsfuzhu commented 1 month ago

Version/Branch of Dear ImGui:

docking

Back-ends:

imgui_impl_dx11.cpp

Compiler, OS:

Windows11 + MSVC2022

Full config/build information:

No response

Details:

Screenshots/Video:

https://github.com/user-attachments/assets/13af910a-6a3b-4f04-ae6d-3d801047a32e

Minimal, Complete and Verifiable Example code:

No response

GamingMinds-DanielC commented 1 month ago

That is not something that can be solved in a general way. Inside of your main viewport you can basically render however you want, but when dragged into a new viewport, a new platform window gets created. Your ImGui window will still be transparent, but it will be transparently rendered on top of whatever is in the back buffer of your platform window (cleared to red in your case). Same as with you main viewport which happens to have a solid background color as well.

You might be able to achieve some transparency on your own if you create transparent platform windows, you can override ImGui::GetPlatformIO().Platform_CreateWindow with your own version for that.

fsfuzhu commented 1 month ago

That is not something that can be solved in a general way. Inside of your main viewport you can basically render however you want, but when dragged into a new viewport, a new platform window gets created. Your ImGui window will still be transparent, but it will be transparently rendered on top of whatever is in the back buffer of your platform window (cleared to red in your case). Same as with you main viewport which happens to have a solid background color as well.

You might be able to achieve some transparency on your own if you create transparent platform windows, you can override ImGui::GetPlatformIO().Platform_CreateWindow with your own version for that.

Sure, thx bro. And could u give me a example for invoking this function? idk how to invoke this, sry

GamingMinds-DanielC commented 1 month ago

It's not a function you invoke yourself, it is a hook for a function that gets called by the library when needed. You just need to replace it with your own version right after initializing the ImGui context. Since you are using DX11, I'm guessing you are using Win32 as a backend as well, so after your call to ImGui_ImplWin32_Init. You have sources for the backends, take a look at ImGui_ImplWin32_CreateWindow (that one is the default for that platform hook) as a reference and build your own based on that.