-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Add support for transparent backbuffers to GLFW contexts (OpenGL3 and Vulkan) #2766
Conversation
Hello Shawn, Writing down some notes for myself, though I think it should not necessarily for you to rework the PR right now (we have all the info we need in the PR, thanks!).
What you could help with:
Thank you! |
4a6447b
to
6822493
Compare
We've now merged the blending fixes to multiple backends and premulitiplied clear color in examples, see bda12e5 and 6a161b8. However there's some remaining related work and various ideas of this PR are not fulfilled yet. Some thoughts:
What I think we will do later:
|
If this feature gets implemented, it would also allow adding a transparent blur effect to ImGui Windows. Here is how it looks using Acrylic on Windows: Resizing the window is laggy, but unfortunately, that's a bug in Windows's function Alternatively, a less "aggressive" blur could be used, which doesn't have issues with resizing (banding is due to compression, natively the blur is smooth): Even without a blur effect, the transparent background looks quite cool, though hardly readable: Edit: I am not suggesting that this should be implemented on the side of ImGui. I only wanted to show off what could be achieved on the user side if transparent viewport framebuffers were a thing. |
In relation to the previous comment, a feature that could be implemented by ImGui if transparent viewport framebuffers would be implemented is rounded window borders. Currently they are always squared off when the window leaves the host viewport, while with transparent framebuffers, the border could be rounded using the alpha channel. |
Temporary patch until ocornut#2766 is merged.
Temporary patch until ocornut/imgui ocornut#2766 is merged.
Wow, so cool. How did this happen? |
Was this intentionally closed/deleted ? I’ve been meaning to keep this open as a base/reference :( |
My apologies! I didn't realize that this PR was still open! I re-forked ImGui to add text justification support and completely slipped my mind that this PR would get nuked. I can recover the old modifications though if they're helpful! |
Modifications are still available but github won’t let me reopen this, i wonder if you can. FYI i have working justification and other features but it’ll be part of a larger set of changes so i can’t merge it so soon. |
Unfortunately I can't re-open either, since the original repo was deleted. I could re-implement the changes on a different branch in the new fork and issue a new PR if that helps. That would need to be sometime tomorrow though, sorry again! |
That would be good if easy, would ensure this is well referenced and not forgotten. |
This PR adds support for the transparent backbuffers provided by ImGui.
It expands on the fix proposed in #2693
This is partially a bug-fix and partially a new feature. These changes fix alpha blending issues when drawing ImGui displays over transparent backbuffers, and also adds support for transparent viewports when using the viewport system.
Note that this also updates GLFW to version 3.3.
Example Image
![image](https://user-images.githubusercontent.com/6020584/63840839-b4893100-c94f-11e9-819a-157c3905c8c7.png)
Transparent framebuffer support is added via the
ImGuiConfigFlags_TransparentBackbuffers
flag.When used in conjunction with GLFW_TRANSPARENT_FRAMEBUFFER, this flag will bypass some constraints that forced a viewport window's alpha to be 1, and allows for windows to be created that support transparent backbuffers.
The color and transparency of the backbuffer come from the style, specifically
ImGuiCol_WindowBg
, wherew
will represent the alpha value of the window being created.In addition to these changes, there is a small tweak to how the OpenGL3 and Vulkan implementations handle alpha blending to ensure proper blending with a transparent backbuffer.
These tweaks can be easily applied to other APIs that GLFW supports, the only change is to update the blend mode and get the clear color from the style instead of being hard coded.
WARNING
the x64 lib for glfw3.lib was not built for vc2010, instead it was built for vc2012. The 32 bit version is still 2010