Fix rendering bug by clearing the index buffer

This commit is contained in:
Dusk 2022-09-04 12:55:23 +02:00
parent 5adc005f6f
commit 331d73d7ab
1 changed files with 6 additions and 12 deletions

View File

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