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

Transparency issues when using GLFW on Wayland #3813

Closed
savchenko opened this issue Feb 15, 2021 · 5 comments
Closed

Transparency issues when using GLFW on Wayland #3813

savchenko opened this issue Feb 15, 2021 · 5 comments

Comments

@savchenko
Copy link

Version/Branch of Dear ImGui:

Version: v1.81
Branch: master (4df5713)

Back-end/Renderer/Compiler/OS

Back-ends: GLFW/OpenGL2 and GLFW/OpenGL3
Compiler: g++ v10.2.1
Operating System: Debian Bullseye (5.10.13 kernel, AMDGPU, Renoir firmware 20.45)
WM: Sway v1.5 (implies Wayland instead of X-Server)

My Issue/Question:

Some UI elements are rendered transparent when this is not expected. The issue can be reproduced with GLFW, but not SDL:

  • GLFW/OpenGL2:
    image

  • GLFW/OpenGL2:
    image

  • SDL/OpenGL3:
    image

  • imgui-rs (ping @thomcc) is affected as well:
    image

Searching via existing bugs reveals #2764, however its author was using Windows.

Standalone, minimal, complete and verifiable example:

N/A, examples are compiled without any changes to the source code.

@ocornut
Copy link
Owner

ocornut commented Feb 15, 2021

In imgui_impl_opengl3.cpp, would changing this line:

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

into

glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

fix it for you?

cc #2766 #3447

@savchenko
Copy link
Author

Unfortunately no, make fails with the following:

g++ -I../.. -I../../backends -g -Wall -Wformat -I../libs/gl3w -DIMGUI_IMPL_OPENGL_LOADER_GL3W `pkg-config --cflags glfw3` -c -o imgui_impl_opengl3.o ../../backends/imgui_impl_opengl3.cpp
../../backends/imgui_impl_opengl3.cpp: In function ‘void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData*, int, int, GLuint)’:
../../backends/imgui_impl_opengl3.cpp:250:85: error: too many arguments to function
  250 |     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
      |                                                                                     ^
make: *** [Makefile:101: imgui_impl_opengl3.o] Error 1

I have opportunistically tried to build from #2766 that you have CC'd above, but it refuses to start on Wayland:

./example_glfw_opengl3 
Glfw Error 65544: Wayland: Focusing a window requires user interaction
Glfw Error 65544: Wayland: Window position retrieval not supported
Glfw Error 65544: Wayland: Window position retrieval not supported
Glfw Error 65544: Wayland: Window position retrieval not supported
Glfw Error 65544: Wayland: Window position setting not supported
Glfw Error 65544: Wayland: Window position setting not supported
xdg_wm_base@9: error 3: xdg_surface must not have a buffer at creation
Glfw Error 65544: Wayland: Window position retrieval not supported
Glfw Error 65544: Wayland: Window position retrieval not supported

@ocornut
Copy link
Owner

ocornut commented Feb 15, 2021

Unfortunately no, make fails with the following:

You didn't use the right code mentioned above.

@savchenko
Copy link
Author

You didn't use the right code mentioned above.

Note to self: do not try to patch things late at night...

@ocornut , you are correct. With the glBlendFuncSeparate() it works perfectly:
16-Feb_10-07-17

Created pull request: #3816

ocornut added a commit that referenced this issue Feb 18, 2021
… accross all backends. (#2693, #2764, #2766, #2873, #3447, #3813, #3816)

Some of the viewport ideas from #2766 are not in there yet (e.g. Vulkan: setting compositeAlpha based on cap.supportedCompositeAlpha)
@ocornut
Copy link
Owner

ocornut commented Feb 18, 2021

Hello @savchenko

We've now merged fixes and applied similar changes to multiple backends and examples, see bda12e5 and 6a161b8. Some remaining related work will be discussed in #2766

As for other Wayland errors if any:

Thank you!

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

Successfully merging a pull request may close this issue.

2 participants