From da600fee8f473ff2e5821c56dd55fef54e41adc6 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 17 Nov 2023 09:47:52 -0800 Subject: [PATCH] renderer/opengl: pull out cell program drawing to dedicated func --- src/renderer/OpenGL.zig | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index ffaabebd9..c0514ef30 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -1407,6 +1407,22 @@ pub fn drawFrame(self: *OpenGL, surface: *apprt.Surface) !void { defer if (single_threaded_draw) self.draw_mutex.unlock(); const gl_state = self.gl_state orelse return; + // Draw our terminal cells + try self.drawCellProgram(&gl_state); + + // Swap our window buffers + switch (apprt.runtime) { + apprt.glfw => surface.window.swapBuffers(), + apprt.gtk => {}, + else => @compileError("unsupported runtime"), + } +} + +/// Runs the cell program (shaders) to draw the terminal grid. +fn drawCellProgram( + self: *OpenGL, + gl_state: *const GLState, +) !void { // Try to flush our atlas, this will only do something if there // are changes to the atlas. try self.flushAtlas(); @@ -1443,15 +1459,9 @@ pub fn drawFrame(self: *OpenGL, surface: *apprt.Surface) !void { self.deferred_font_size = null; } + // Draw our background, then draw the fg on top of it. try self.drawCells(bind.vbo, self.cells_bg); try self.drawCells(bind.vbo, self.cells); - - // Swap our window buffers - switch (apprt.runtime) { - apprt.glfw => surface.window.swapBuffers(), - apprt.gtk => {}, - else => @compileError("unsupported runtime"), - } } /// Loads some set of cell data into our buffer and issues a draw call.