From 331d73d7ab67614c787bcf60d02f94416aa2f8bc Mon Sep 17 00:00:00 2001 From: Strangedusk Date: Sun, 4 Sep 2022 12:55:23 +0200 Subject: [PATCH] Fix rendering bug by clearing the index buffer --- src/Renderer.zig | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/Renderer.zig b/src/Renderer.zig index eac75be..f1d740b 100644 --- a/src/Renderer.zig +++ b/src/Renderer.zig @@ -108,22 +108,16 @@ pub fn render(self: *Self) void { self.buffer.data(f32, &self.vbo, .static_draw); - // { - // var i: usize = 0; - // while (i < self.vbo_index) { - // gl.uniform4fv(self.color_loc, &.{self.colors[i]}); - // //std.debug.print("Color: {any}\n", .{self.colors[i]}); - // gl.drawArrays(.triangles, i, 12); - // i += 12; - // } - // } - gl.drawArrays(.triangles, 0, self.vbo_index); + sdl.gl.swapWindow(self.window); + gl.clear(.{ .color = true }); self.vbo_index = 0; - sdl.gl.swapWindow(self.window); - gl.clear(.{ .color = true }); + // Clear the vbo, this really shouldn't be necessary as the index is set to zero, + // but otherwise it leads to bugs + self.vbo = .{0.0} ** max_objects; + } pub fn deinit(self: *Self) void {