opengl: flip Y axis during framebuffer blit

This commit is contained in:
Leah Amelia Chen
2026-09-09 23:14:32 +08:00
parent 202fa8e390
commit d00a498274
2 changed files with 6 additions and 11 deletions

View File

@@ -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) },

View File

@@ -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,
);