mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-09-19 20:18:07 +00:00
opengl: flip Y axis during framebuffer blit
This commit is contained in:
@@ -158,15 +158,6 @@ pub const RenderSurface = extern struct {
|
||||
const h = widget.getHeight();
|
||||
if (w == 0 or h == 0) return;
|
||||
|
||||
// In OpenGL +Y is up but in GSK (and DirectX, Metal, Vulkan, etc.)
|
||||
// +Y is down. We therefore might need to flip the rendered image.
|
||||
snap.save();
|
||||
defer snap.restore();
|
||||
if (comptime !rendererpkg.Renderer.API.custom_shader_y_is_down) {
|
||||
snap.translate(&.{ .f_x = 0, .f_y = @floatFromInt(h) });
|
||||
snap.scale(1, -1);
|
||||
}
|
||||
|
||||
snap.appendTexture(texture, &.{
|
||||
.f_origin = .{ .f_x = 0, .f_y = 0 },
|
||||
.f_size = .{ .f_width = @floatFromInt(w), .f_height = @floatFromInt(h) },
|
||||
|
||||
@@ -165,15 +165,19 @@ pub fn exportDmabuf(
|
||||
const draw_bind = try self.export_framebuffer.bind(.draw);
|
||||
defer draw_bind.unbind();
|
||||
|
||||
// Flip the Y axis during the blit so apprts don't have to
|
||||
// handle this. We do this explicitly in OpenGL only
|
||||
// because it's the only one that thinks +Y should point up
|
||||
// for some reason.
|
||||
try gl.blitFramebuffer(
|
||||
0,
|
||||
0,
|
||||
@intCast(self.width),
|
||||
@intCast(self.height),
|
||||
0,
|
||||
0,
|
||||
@intCast(self.width),
|
||||
@intCast(self.height),
|
||||
@intCast(self.width),
|
||||
0,
|
||||
.{ .color_buffer_bit = true },
|
||||
.nearest,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user