-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting background alpha for specific viewports in glfw and win32/dx11 [SOLVED] #6558
Comments
Dear ImGui currently does not support secondary viewports with transparent backgrounds. (Alpha is explicitly ignored for viewport-owned windows) See also #2766
This sounds like a bug, but I cannot reproduce it on my machine with |
Oh sorry I think I may have been unclear / still struggling with the window naming terminology - I'm totally happy with the behaviour of the owned viewports I want this: but it looks like this isn't currently supported as per this: Regarding your helpful response (which provided me the path to clarify that issue had already been described) If that were the case it should be possible to force everything to be transparent with something like the following at approx L6349. However this doesn't work
|
I've made a bit of (maybe) progress - in that I can now make the main viewport transparent - but it doesn't work for single-window viewports Inside the client bounds of the main-viewport it's perfect But if it is moved outside those bounds the transparency fails Getting this far only requires a small change to core code
incidentally for those not sure it only takes a minute to upgrade - you just download glfw replace the following files and change the linker target to lib-vc2022 (or whatever version you're using). https://www.glfw.org/download.html |
Finally got a couple of hours to get back to this question. in "imgui_impl_opengl3.h"
in "imgui_impl_opengl3.cpp" remove static from the declaration so it becomes
//New functions
In the main setup code flow
In the rendering loop
|
@dgm3333 I tried your solution on my directx9 win32 app. It gave me IM_ASSERT error and crashed when i dragged the window outside of the main viewport. |
as per the title I was after a glfw specific solution. However with minor modifications it also works for win32/dx11. Then add these functions I was trying to get some additional effects with the dwm library - but they aren't working in the way I wanted.
|
@dgm3333 Thank you! |
@dgm3333 After testing, it definitely works for directx9 too. Although i realized that i need to make only the background (WindowBg) transparent, not the entire viewport. Do you know how to do that in dx9? Sorry to bother you more. |
That's pretty easy to do in the initial window creation function with SetLayeredWindowAttributes - you just keep the alpha at 255 and set the colour key to a specific colour you don't want as the transparent colour - then anything in that colour will be transparent. If you put the function and the change you want into chatGPT (or the free Bing version) then it will probably make a good stab at the code you want. However I think this should do it:
|
I want to create a transparent / overlay viewport.
With the following code it is correctly semi-transparent when over the main viewport (ie can see the main viewport through it).
However as soon as it is dragged outside the main viewport and becomes a single-window viewport it immediately becomes opaque.
I've tried these three variations for setting the alpha
I've tried with glfw and win32 dx11,dx12 with identical results
win32/ogl3 is the odd one out as the window appears to entirely disappear if it is in the main viewport (but is still opaque if it's outside the bounds)
The text was updated successfully, but these errors were encountered: