> My quads were not parallelograms so I am planning on cutting them into four
> triangles and a rectangle. I found the bresenham line routine so I'll be
> able to work on that tonight, thanks.
better approach is to work with fractions.
To follow an edge from x1,y1 to x2,y2 with y1<y2 first work out dx=x2-x1
and dy=y2-y1. Then divide dx by dy TO GET INTEGER QUOTIENT q AND
REMAINDER r (much quicker than a full divide as the answer is almost
always quotient=0 or quotient=-1). These are effectively a fraction.
Then you set a variable x equal to x1, the integer part of the
x-coordinate, and another n to 0, the numerator of the fractional part.
For each row, add r to n and if it exceeds dy do n-=r and x+=1.
Before anybody remarks that actually this is closely related to
Bresenham: all the algorithms are related to each other, aren't they?
All you need now is a fast way of plotting a row of your texture. Again,
I would not recommend the approach you suggest. A tried and tested
method is to cut your horizontal rows into 16-ish-pixel sections, do a
proper perspective-correct mapping calculation at the junctions, and
interpolate in between. This is just as fast and much easier to write,
after you've done the maths, as managing multiple triangles and making
sure they join up is quite a headache, especially when they get near or
even partially behind the viewpoint. This is less important in a demo,
of course, where you have good control over where the triangles go.