1
0
Fork 0
forked from AbleOS/ableos
This commit is contained in:
peony 2024-10-25 17:58:19 +02:00
parent d143acb8b6
commit 4a0f65753e

View file

@ -329,7 +329,7 @@ put_hline := fn(surface: Surface, y: uint, x0: uint, x1: uint, color: Color): vo
return return
} }
put_tri_wireframe := fn(surface: Surface, p0: Vec2(int), p1: Vec2(int), p2: Vec2(int), color: Color): void { put_tri_wireframe := fn(surface: Surface, p0: Vec2(uint), p1: Vec2(uint), p2: Vec2(uint), color: Color): void {
put_line(surface, p0, p1, color) put_line(surface, p0, p1, color)
put_line(surface, p1, p2, color) put_line(surface, p1, p2, color)
put_line(surface, p2, p0, color) put_line(surface, p2, p0, color)
@ -355,8 +355,24 @@ put_tri_filled := fn(surface: Surface, p0: Vec2(uint), p1: Vec2(uint), p2: Vec2(
p2 = tmp p2 = tmp
} }
primary_dx := @as(int, @bitcast(p2.x - p0.x))
primary_dy := @as(int, @bitcast(p2.y - p0.y))
primary_error := @as(int, 2) * primary_dx - primary_dy
secondary_dx := @as(int, @bitcast(p1.x - p0.x))
secondary_dy := @as(int, @bitcast(p1.y - p0.y))
secondary_error := @as(int, 2) * secondary_dx - secondary_dy
y := p0.y y := p0.y
loop if y > p2.y break else { loop if y > p2.y break else {
if primary_error > 0 {
x += xi
primary_error += 2 * (dx - dy)
} else {
primary_error += 2 * dx
}
y += 1 y += 1
} }