2

When an imgui window is floating, I can make it transparent with ImGuiWindowFlags_NoBackground and render a translucent texture before the interface.

However when the window is docked, It shows a dark background which I do not want or need.

By window I do not mean the OS window. I mean the dockable child windows that imgui creates inside the OS window

How do I turn off the background for all the docks?

rxantos
  • 1,724
  • 1
  • 13
  • 14

2 Answers2

2

The following code can be used to change the color of the imgui background, it takes a vec4 meaning (R, G, B, A).

You want to change the A channel. 0.5

auto& style = ImGui::GetStyle();
ImVec4* colors = style.Colors;

//                                            \/
const ImVec4 bgColor = ImVec4(0.1, 0.1, 0.1, 0.5);
colors[ImGuiCol_WindowBg] = bgColor;
colors[ImGuiCol_ChildBg] = bgColor;
colors[ImGuiCol_TitleBg] = bgColor;

You can use the following function if you just want to change the next imgui window and not all of them.

ImGui::SetNextWindowBgAlpha(0.35f); // Transparent background
Alex
  • 21
  • 3
0

For docking windows you need to use ImGuiDockNodeFlags_PassthruCentralNode in docking flags to get transparent windows (additional to ImGuiWindowFlags_NoBackground window flag)

holydel
  • 3
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 21 '23 at 09:19