Fix rendering bug by clearing the index buffer
This commit is contained in:
parent
5adc005f6f
commit
331d73d7ab
|
@ -108,22 +108,16 @@ pub fn render(self: *Self) void {
|
||||||
|
|
||||||
self.buffer.data(f32, &self.vbo, .static_draw);
|
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);
|
gl.drawArrays(.triangles, 0, self.vbo_index);
|
||||||
|
sdl.gl.swapWindow(self.window);
|
||||||
|
gl.clear(.{ .color = true });
|
||||||
|
|
||||||
self.vbo_index = 0;
|
self.vbo_index = 0;
|
||||||
|
|
||||||
sdl.gl.swapWindow(self.window);
|
// Clear the vbo, this really shouldn't be necessary as the index is set to zero,
|
||||||
gl.clear(.{ .color = true });
|
// but otherwise it leads to bugs
|
||||||
|
self.vbo = .{0.0} ** max_objects;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: *Self) void {
|
pub fn deinit(self: *Self) void {
|
||||||
|
|
Loading…
Reference in New Issue