Skip to content

Commit

Permalink
Use premultiplied alpha for renderer clearColor (#3347)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mitchellh authored Dec 29, 2024
2 parents b50e087 + 28bbd52 commit c8950d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/renderer/Metal.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1186,9 +1186,9 @@ pub fn drawFrame(self: *Metal, surface: *apprt.Surface) !void {
attachment.setProperty("storeAction", @intFromEnum(mtl.MTLStoreAction.store));
attachment.setProperty("texture", screen_texture.value);
attachment.setProperty("clearColor", mtl.MTLClearColor{
.red = @as(f32, @floatFromInt(self.current_background_color.r)) / 255,
.green = @as(f32, @floatFromInt(self.current_background_color.g)) / 255,
.blue = @as(f32, @floatFromInt(self.current_background_color.b)) / 255,
.red = @as(f32, @floatFromInt(self.current_background_color.r)) / 255 * self.config.background_opacity,
.green = @as(f32, @floatFromInt(self.current_background_color.g)) / 255 * self.config.background_opacity,
.blue = @as(f32, @floatFromInt(self.current_background_color.b)) / 255 * self.config.background_opacity,
.alpha = self.config.background_opacity,
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/OpenGL.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2344,9 +2344,9 @@ fn drawCellProgram(

// Clear the surface
gl.clearColor(
@as(f32, @floatFromInt(self.draw_background.r)) / 255,
@as(f32, @floatFromInt(self.draw_background.g)) / 255,
@as(f32, @floatFromInt(self.draw_background.b)) / 255,
@floatCast(@as(f32, @floatFromInt(self.draw_background.r)) / 255 * self.config.background_opacity),
@floatCast(@as(f32, @floatFromInt(self.draw_background.g)) / 255 * self.config.background_opacity),
@floatCast(@as(f32, @floatFromInt(self.draw_background.b)) / 255 * self.config.background_opacity),
@floatCast(self.config.background_opacity),
);
gl.clear(gl.c.GL_COLOR_BUFFER_BIT);
Expand Down

0 comments on commit c8950d3

Please sign in to comment.