mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
use main buffer and copy data to fbo texture
DO NOT MERGE.
This commit is contained in:

committed by
Mitchell Hashimoto

parent
cd57612059
commit
af9a552d19
@ -162,4 +162,26 @@ pub const Binding = struct {
|
|||||||
data,
|
data,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn copySubImage2D(
|
||||||
|
b: Binding,
|
||||||
|
level: c.GLint,
|
||||||
|
xoffset: c.GLint,
|
||||||
|
yoffset: c.GLint,
|
||||||
|
x: c.GLint,
|
||||||
|
y: c.GLint,
|
||||||
|
width: c.GLsizei,
|
||||||
|
height: c.GLsizei,
|
||||||
|
) !void {
|
||||||
|
glad.context.CopyTexSubImage2D.?(
|
||||||
|
@intFromEnum(b.target),
|
||||||
|
level,
|
||||||
|
xoffset,
|
||||||
|
yoffset,
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
width,
|
||||||
|
height
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -2363,26 +2363,18 @@ fn drawCustomPrograms(self: *OpenGL, custom_state: *custom.State) !void {
|
|||||||
// Setup the new frame
|
// Setup the new frame
|
||||||
try custom_state.newFrame();
|
try custom_state.newFrame();
|
||||||
|
|
||||||
// To allow programs to retrieve each other via a texture
|
// const fbobind = try custom_state.fbo.bind(.framebuffer);
|
||||||
// then we must render the next shaders to the screen fbo.
|
// defer fbobind.unbind();
|
||||||
// However, the first shader must be run while the default fbo
|
|
||||||
// is attached
|
|
||||||
{
|
|
||||||
const bind = try custom_state.programs[0].bind();
|
|
||||||
defer bind.unbind();
|
|
||||||
try bind.draw();
|
|
||||||
if (custom_state.programs.len == 1) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const fbobind = try custom_state.fbo.bind(.framebuffer);
|
|
||||||
defer fbobind.unbind();
|
|
||||||
|
|
||||||
// Go through each custom shader and draw it.
|
// Go through each custom shader and draw it.
|
||||||
for (custom_state.programs[1..]) |program| {
|
for (custom_state.programs) |program| {
|
||||||
// Bind our cell program state, buffers
|
// Bind our cell program state, buffers
|
||||||
const bind = try program.bind();
|
const bind = try program.bind();
|
||||||
defer bind.unbind();
|
defer bind.unbind();
|
||||||
try bind.draw();
|
try bind.draw();
|
||||||
|
|
||||||
|
// copy main and custom fbo
|
||||||
|
try custom_state.copy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,6 +230,14 @@ pub const State = struct {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// copy the fbo's attached texture to the backbuffer
|
||||||
|
pub fn copy(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]));
|
||||||
|
}
|
||||||
|
|
||||||
pub const Binding = struct {
|
pub const Binding = struct {
|
||||||
vao: gl.VertexArray.Binding,
|
vao: gl.VertexArray.Binding,
|
||||||
ebo: gl.Buffer.Binding,
|
ebo: gl.Buffer.Binding,
|
||||||
|
Reference in New Issue
Block a user