renderer/opengl: small tweaks

This commit is contained in:
Mitchell Hashimoto
2025-01-23 12:44:25 -08:00
parent be5828b5b6
commit 480489bdce
2 changed files with 12 additions and 8 deletions

View File

@ -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();
}
}

View File

@ -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 {