From bebf6bb1089add058d633058ccf358c3a572add2 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 22 Sep 2023 09:45:26 -0700 Subject: [PATCH] renderer/opengl: only skip drawing cells if they're empty, not clear Fixes #518 This optimization to avoid a draw call to OpenGL was premature. This optimization is fine but needs to happen only for the draw calls. We still need to clear the screen if we have no cells. This was causing #518 because when the cursor was blinked (invisible) then we had no cells so we'd skip the draw call which reused the old buffer state for OpenGL. --- src/renderer/OpenGL.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index 4551472db..87f8e5675 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -1434,9 +1434,6 @@ pub fn draw(self: *OpenGL) !void { defer if (single_threaded_draw) self.draw_mutex.unlock(); const gl_state = self.gl_state orelse return; - // If we have no cells to render, then we render nothing. - if (self.cells.items.len == 0) return; - // Try to flush our atlas, this will only do something if there // are changes to the atlas. try self.flushAtlas(); @@ -1499,6 +1496,9 @@ fn drawCells( binding: gl.Buffer.Binding, cells: std.ArrayListUnmanaged(GPUCell), ) !void { + // If we have no cells to render, then we render nothing. + if (cells.items.len == 0) return; + // Todo: get rid of this completely self.gl_cells_written = 0;