Transparency issues when using GLFW on Wayland #3813

Closed
opened 2021-02-15 03:53:30 +00:00 by savchenko · 5 comments
savchenko commented 2021-02-15 03:53:30 +00:00 (Migrated from github.com)

Version/Branch of Dear ImGui:

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

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 https://github.com/ocornut/imgui/issues/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.

**Version/Branch of Dear ImGui:** Version: v1.81 Branch: master (4df57136e9832327c11e48b5bfe00b0326bd5b63) **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](https://user-images.githubusercontent.com/300146/107902797-63cc2480-6f97-11eb-93f1-d4bf6fe8819c.png) - GLFW/OpenGL2: ![image](https://user-images.githubusercontent.com/300146/107902862-8cecb500-6f97-11eb-8663-03bbacd88b9a.png) - SDL/OpenGL3: ![image](https://user-images.githubusercontent.com/300146/107902897-aaba1a00-6f97-11eb-8c7b-99fa7562785f.png) - [imgui-rs](https://github.com/imgui-rs/imgui-rs) (ping @thomcc) is affected as well: ![image](https://user-images.githubusercontent.com/300146/107903362-f7eabb80-6f98-11eb-8ea5-ec61fd5e69c7.png) Searching via existing bugs reveals https://github.com/ocornut/imgui/issues/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 commented 2021-02-15 08:57:06 +00:00 (Migrated from github.com)

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

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 commented 2021-02-15 11:05:40 +00:00 (Migrated from github.com)

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 https://github.com/ocornut/imgui/pull/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
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 https://github.com/ocornut/imgui/pull/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 commented 2021-02-15 11:13:34 +00:00 (Migrated from github.com)

Unfortunately no, make fails with the following:

You didn't use the right code mentioned above.

> Unfortunately no, make fails with the following: You didn't use the right code mentioned above.
savchenko commented 2021-02-16 00:06:50 +00:00 (Migrated from github.com)

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: https://github.com/ocornut/imgui/pull/3816

> 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](https://user-images.githubusercontent.com/300146/108002335-3b980080-703f-11eb-8f67-a13c77a11384.png) Created pull request: https://github.com/ocornut/imgui/pull/3816
ocornut commented 2021-02-18 12:54:53 +00:00 (Migrated from github.com)

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:

  • if not related to multi-viewports please post a separate issue and try to narrow down the GLFW calls leading to those printouts.
  • if related to multi-viewports please post to https://github.com/ocornut/imgui/issues/2117

Thank you!

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: - if not related to multi-viewports please post a separate issue and try to narrow down the GLFW calls leading to those printouts. - if related to multi-viewports please post to https://github.com/ocornut/imgui/issues/2117 Thank you!
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#3813
No description provided.