From d00a498274f321b8808ba89d63c4e23d93a7d8e0 Mon Sep 17 00:00:00 2001 From: Leah Amelia Chen Date: Wed, 9 Sep 2026 23:14:32 +0800 Subject: [PATCH] opengl: flip Y axis during framebuffer blit --- src/apprt/gtk/class/render_surface.zig | 9 --------- src/renderer/opengl/Target.zig | 8 ++++++-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/apprt/gtk/class/render_surface.zig b/src/apprt/gtk/class/render_surface.zig index e995e880a..f4ac78cab 100644 --- a/src/apprt/gtk/class/render_surface.zig +++ b/src/apprt/gtk/class/render_surface.zig @@ -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) }, diff --git a/src/renderer/opengl/Target.zig b/src/renderer/opengl/Target.zig index 7bc844221..55e7e3384 100644 --- a/src/renderer/opengl/Target.zig +++ b/src/renderer/opengl/Target.zig @@ -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, );