mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-09 11:26:41 +00:00
renderer/opengl: draw custom shaders, simplified
This commit is contained in:
@@ -1410,6 +1410,9 @@ pub fn drawFrame(self: *OpenGL, surface: *apprt.Surface) !void {
|
||||
// Draw our terminal cells
|
||||
try self.drawCellProgram(&gl_state);
|
||||
|
||||
// Draw our custom shaders
|
||||
try self.drawCustomPrograms(&gl_state);
|
||||
|
||||
// Swap our window buffers
|
||||
switch (apprt.runtime) {
|
||||
apprt.glfw => surface.window.swapBuffers(),
|
||||
@@ -1418,6 +1421,20 @@ pub fn drawFrame(self: *OpenGL, surface: *apprt.Surface) !void {
|
||||
}
|
||||
}
|
||||
|
||||
fn drawCustomPrograms(
|
||||
self: *OpenGL,
|
||||
gl_state: *const GLState,
|
||||
) !void {
|
||||
_ = self;
|
||||
|
||||
for (gl_state.custom_programs) |program| {
|
||||
// Bind our cell program state, buffers
|
||||
const bind = try program.bind();
|
||||
defer bind.unbind();
|
||||
try gl.drawElementsInstanced(gl.c.GL_TRIANGLES, 6, gl.c.GL_UNSIGNED_BYTE, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/// Runs the cell program (shaders) to draw the terminal grid.
|
||||
fn drawCellProgram(
|
||||
self: *OpenGL,
|
||||
|
Reference in New Issue
Block a user