From 480489bdce6f6d5331794a572ef0a7436f9c8a1f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 23 Jan 2025 12:44:25 -0800 Subject: [PATCH] renderer/opengl: small tweaks --- src/renderer/OpenGL.zig | 5 +---- src/renderer/opengl/custom.zig | 15 +++++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index b0fcdfc3a..3e674c715 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -2365,13 +2365,10 @@ fn drawCustomPrograms(self: *OpenGL, custom_state: *custom.State) !void { // Go through each custom shader and draw it. for (custom_state.programs) |program| { - // Bind our cell program state, buffers const bind = try program.bind(); defer bind.unbind(); try bind.draw(); - - // copy main and custom fbo - try custom_state.copy(); + try custom_state.copyFramebuffer(); } } diff --git a/src/renderer/opengl/custom.zig b/src/renderer/opengl/custom.zig index a69fc8b2b..859277ce5 100644 --- a/src/renderer/opengl/custom.zig +++ b/src/renderer/opengl/custom.zig @@ -230,12 +230,19 @@ pub const State = struct { }; } - /// copy the fbo's attached texture to the backbuffer - pub fn copy(self: *State) !void { + /// Copy the fbo's attached texture to the backbuffer. + pub fn copyFramebuffer(self: *State) !void { const texbind = try self.fb_texture.bind(.@"2D"); errdefer texbind.unbind(); - - try texbind.copySubImage2D(0, 0, 0, 0, 0, @intFromFloat(self.uniforms.resolution[0]), @intFromFloat(self.uniforms.resolution[1])); + try texbind.copySubImage2D( + 0, + 0, + 0, + 0, + 0, + @intFromFloat(self.uniforms.resolution[0]), + @intFromFloat(self.uniforms.resolution[1]), + ); } pub const Binding = struct {