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

Use premultiplied alpha for renderer clearColor #3347

Conversation

lixiaoyan
Copy link
Contributor

@lixiaoyan lixiaoyan commented Dec 27, 2024

Fixes #3324


I haven't tested it on Linux yet, but I believe it has the similar problem and could be fixed by this PR as well.

src/renderer/OpenGL.zig Outdated Show resolved Hide resolved
@SimonYde
Copy link

SimonYde commented Dec 27, 2024

I cannot get this to build on my linux machine using flake.nix:

>    └─ zig build-exe ghostty Debug native-native 1 errors
┃        > src/renderer/OpenGL.zig:2347:63: error: expected type 'f32', found 'f64'
┃        >         @as(f32, @floatFromInt(self.draw_background.r)) / 255 * self.config.background_opacit…
┃        >         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
┃        > pkg/opengl/draw.zig:5:22: note: parameter type declared here
┃        > pub fn clearColor(r: f32, g: f32, b: f32, a: f32) void {
┃        >                      ^~~
┃        > referenced by:
┃        >     drawFrame: src/renderer/OpenGL.zig:2289:13
┃        >     render: src/apprt/gtk/Surface.zig:669:35
┃        >     remaining reference traces hidden; use '-freference-trace' to see all reference traces
┃        > error: the following command failed with 1 compilation errors:
┃        > /nix/store/v9xybfsc2iyfd602s192pymyrrncni0n-zig-0.13.0/bin/zig build-exe /build/source/.zig-c…
┃        > Build Summary: 94/97 steps succeeded; 1 failed (disable with --summary none)
┃        > install transitive failure
┃        > └─ install ghostty transitive failure
┃        >    └─ zig build-exe ghostty Debug native-native 1 errors

Appears to be a type mismatch issue.

@gerblesh
Copy link
Contributor

I cannot get this to build on my linux machine using flake.nix:

>    └─ zig build-exe ghostty Debug native-native 1 errors
┃        > src/renderer/OpenGL.zig:2347:63: error: expected type 'f32', found 'f64'
┃        >         @as(f32, @floatFromInt(self.draw_background.r)) / 255 * self.config.background_opacit…
┃        >         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
┃        > pkg/opengl/draw.zig:5:22: note: parameter type declared here
┃        > pub fn clearColor(r: f32, g: f32, b: f32, a: f32) void {
┃        >                      ^~~
┃        > referenced by:
┃        >     drawFrame: src/renderer/OpenGL.zig:2289:13
┃        >     render: src/apprt/gtk/Surface.zig:669:35
┃        >     remaining reference traces hidden; use '-freference-trace' to see all reference traces
┃        > error: the following command failed with 1 compilation errors:
┃        > /nix/store/v9xybfsc2iyfd602s192pymyrrncni0n-zig-0.13.0/bin/zig build-exe /build/source/.zig-c…
┃        > Build Summary: 94/97 steps succeeded; 1 failed (disable with --summary none)
┃        > install transitive failure
┃        > └─ install ghostty transitive failure
┃        >    └─ zig build-exe ghostty Debug native-native 1 errors

Appears to be a type mismatch issue.

Should be fixed with the above suggestion

@SimonYde
Copy link

SimonYde commented Dec 27, 2024

works just fine on linux now (as in it appears to fix #3324) 👍

@yspreen
Copy link

yspreen commented Dec 28, 2024

works wonders on macOS. does fix #3324

@mitchellh mitchellh force-pushed the use-premultiplied-alpha-for-renderer-clear-color branch from e6a42f0 to 28bbd52 Compare December 29, 2024 03:37
@mitchellh mitchellh merged commit c8950d3 into ghostty-org:main Dec 29, 2024
5 checks passed
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.

background-opacity does not function properly
5 participants