ive been thinking and as cool as this is you can speed this up a bit devils child.
from here.
If p1y <> p2y Then
For y = p1y To p2y
If y => 0 Then
If y => vglViewportH Then Exit
x1 = vgliIntpf(y, p1y, p3y, p1x, p3x)
;d1# = vgliIntpf(y, p1y, p3y, p1d, p3d)
d1# = vgliIntpf(y, p1y, p3y, pc1, pc3)
u1# = vgliIntpf(y, p1y, p3y, p1u, p3u)
v1# = vgliIntpf(y, p1y, p3y, p1v, p3v)
x2 = vgliIntpf(y, p1y, p2y, p1x, p2x)
;d2# = vgliIntpf(y, p1y, p2y, p1d, p2d)
d2# = vgliIntpf(y, p1y, p2y, pc1, pc2)
u2# = vgliIntpf(y, p1y, p2y, p1u, p2u)
v2# = vgliIntpf(y, p1y, p2y, p1v, p2v)
vgliFillTriLine(x1, d1, u1, v1, x2, d2, u2, v2, y)
EndIf
Next
EndIf
If p2y <> p3y Then
For y = p2y To p3y
If y => 0 Then
If y => vglViewportH Then Exit
x1 = vgliIntpf(y, p1y, p3y, p1x, p3x)
;d1# = vgliIntpf(y, p1y, p3y, p1d, p3d)
d1# = vgliIntpf(y, p1y, p3y, pc1, pc3)
u1# = vgliIntpf(y, p1y, p3y, p1u, p3u)
v1# = vgliIntpf(y, p1y, p3y, p1v, p3v)
x2 = vgliIntpf(y, p2y, p3y, p2x, p3x)
;d2# = vgliIntpf(y, p2y, p3y, p2d, p3d)
d2# = vgliIntpf(y, p2y, p3y, pc2, pc3)
u2# = vgliIntpf(y, p2y, p3y, p2u, p3u)
v2# = vgliIntpf(y, p2y, p3y, p2v, p3v)
vgliFillTriLine(x1, d1, u1, v1, x2, d2, u2, v2, y)
EndIf
Next
EndIf
there is far more divides in there than there needs to be ideally you dont need any you can do this with just adds ie
for x2 you add a fractional amount for each y scanline by running it through this function
Function vgliIntp(value, vMin, vMax, retMin, retMax)
Return retMin + (value - vMin) * (retMax - retMin) / (vMax - vMin)
End Function
but if you had to precompute the fractional amount before the for loop then you might have something like this before the for loop
PrecomputedXFraction = ( X1 - X2 ) / (Y1 - Y2)
X2 = p2x
and in the for loop you would just do
x2 = x2 + PrecomputedXFraction
and the same can be done for all the others does that make sense, if you have a look at my renderer you will see thats what i do.