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.
This commit is contained in:
Mitchell Hashimoto
2023-09-22 09:45:26 -07:00
parent d287e741b1
commit bebf6bb108

View File

@ -1434,9 +1434,6 @@ pub fn draw(self: *OpenGL) !void {
defer if (single_threaded_draw) self.draw_mutex.unlock(); defer if (single_threaded_draw) self.draw_mutex.unlock();
const gl_state = self.gl_state orelse return; 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 // Try to flush our atlas, this will only do something if there
// are changes to the atlas. // are changes to the atlas.
try self.flushAtlas(); try self.flushAtlas();
@ -1499,6 +1496,9 @@ fn drawCells(
binding: gl.Buffer.Binding, binding: gl.Buffer.Binding,
cells: std.ArrayListUnmanaged(GPUCell), cells: std.ArrayListUnmanaged(GPUCell),
) !void { ) !void {
// If we have no cells to render, then we render nothing.
if (cells.items.len == 0) return;
// Todo: get rid of this completely // Todo: get rid of this completely
self.gl_cells_written = 0; self.gl_cells_written = 0;