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

Fix compositing mixing with framebuffer for web and ANGLE #3224

Closed
wants to merge 1 commit into from
Closed

Fix compositing mixing with framebuffer for web and ANGLE #3224

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Aug 6, 2023

Adds a #if defined(GRAPHICS_API_OPENGL_ES2) to clear the alpha channel on the end of the frame at the end of rlDrawRenderBatch() (R2894-R2900). It does that by:

  1. Setting the clearColor alpha to 1;
  2. Setting a colorMask to only consider the alpha from that clearColor;
  3. Clearing it;
  4. Restoring the colorMask to consider all values.

Removes background-color: black; from minshell.html (L35) and background: black; from shell.html (L78), since with the previous changes they are no longer needed. Those can still be set, but ClearBackground() will take precedence in defining the background color.

Tested these changes successfully on Firefox (102.11.0esr 64-bit) and Chrome (115.0.5790.110) on Linux (Linux Mint 21.1 x86_64).

@ypujante Could you please test/confirm if these changes fix the issue on ANGLE?

@raysan5 I tried my best to place that where I think is the end of the frame. If these proposed changes are accepted, could you please check if that's the ideal/correct place for them?

Fixes #3179.

Edit: added line marks.

@raysan5
Copy link
Owner

raysan5 commented Aug 6, 2023

@ubkp I'm not sure about this change, does it consider the case that some applications could require a transparent background (some of my tools require it). Also, it should be probably called at EndDrawing() but calling it partially removes framebuffer cleaning control from user and it can derive in other unexpected issues, actually framebuffer cleaning was originally inside BeginDrawing() and it was problematic, so ClearBackground() was added.

@ghost
Copy link
Author

ghost commented Aug 6, 2023

@raysan5 Very excellent points!

Regarding transparency, I tested it on PLATFORM_DESKTOP with FLAG_WINDOW_TRANSPARENT and the change didn't break the window background transparency, neither its elements transparencies. But it would completely disable background transparency for anyone using OpenGL ES 2.0 (and break overlapping transparency of elements on OpenGL ES 2.0), which, indeed, I had not considered, my bad.

I'll try to find a better solution.

@ghost ghost closed this Aug 6, 2023
@ghost ghost deleted the fix/transparency branch August 6, 2023 13:24
This pull request was closed.
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.

[rcore] Issue with texture with transparency when using open gl es2.0 (google angle) on macos
1 participant