renderer/opengl: draw custom shaders, simplified

This commit is contained in:
Mitchell Hashimoto
2023-11-17 09:58:28 -08:00
parent da600fee8f
commit 5fc91401f2
4 changed files with 54 additions and 4 deletions

View File

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