Skip to content
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

Write alpha for ImGui draw ops. #687

Merged
merged 2 commits into from
Jul 10, 2022

Conversation

luigi-rosso
Copy link
Contributor

This allows ImGui draw ops to write their alpha values to the framebuffer.

This is nice for when you draw Imgui into one buffer that you later want to blit over the rest of your screen, or similarly if you're drawing with two separate MtkViews with Metal and have one transparently layered over the other.

I ran into a case where I was clearing the frame buffer to fully transparent, drawing imgui onto it and then blitting that framebuffer elsewhere. It was showing up fully transparent (no imgui content visible) because imgui is drawing with no alpha write mask.

@floooh
Copy link
Owner

floooh commented Jul 9, 2022

In general a good idea, but it shouldn't be enabled by default because it may have undesired behaviour on some platforms (for instance on the web where the WebGL canvas is always alpha-blended with the background, this was the reason why I limted rendering to RGB in the first place). Please add a new config boolean around here:

bool disable_paste_override; // if true, don't send Ctrl-V on EVENTTYPE_CLIPBOARD_PASTED

(I think simgui_desc.write_alpha_channel would be a good name, and the default behaviour should be that alpha is not written).

Also I think the alpha-blend factors don't do the right thing if you want to compose an ImGui-rendered texture with something else. I would think that the alpha-values during Imgui-rendering need to be added on top of each other (which would be src=one/dst=one).

@luigi-rosso
Copy link
Contributor Author

Great, thanks for the pointers on how to do it! Yeah I'm not sure about the alpha values, but in my simple examples both adding (one/one and srcOver worked), but I didn't try complex multi-blend pixels on the framebuffer...

@floooh
Copy link
Owner

floooh commented Jul 10, 2022

Look good thanks! I'll merge this first and then rebase the mouse-cursor WIP branch on top and merge that afterwards (there will be collisions because I also worked on sokol_imgui.h, but I'll handle those in my branch).

@floooh floooh merged commit 1479af4 into floooh:master Jul 10, 2022
@floooh
Copy link
Owner

floooh commented Jul 10, 2022

And merged, thanks!

@floooh
Copy link
Owner

floooh commented Jul 10, 2022

PS: I'll update the changelog later today together with the mouse cursor changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants