Ok,

Here my scan line converter algorithm in pseudo-code

3 points for you polygon:

x1,y1

x2,y2

x3,y3

**first create two int buffer with size=screen height to old xmin and xmax for each line**int bufferXmin[screenHeight];

int bufferXmax[screenHeight];

**Get your ymin and your ymax from your three points**ymin=min(y1,y2,y3)

ymax=max(y1,y2,y3)

**inititlaise buffer in range from ymin to ymax : ** with screenWidth for bufferXmin and -1 for bufferXmax (so that xmin>xmax in the range ymin to ymax)

1 2 3 4 5
| for(int y=ymin;y<ymax:y++) { bufferXmin[y]=screenWidth; bufferXmax[y]=-1; } |

than draw your 3 lines by y and update buffer to find xmin and xmax for each y in the range ymin to ymax, something like that :1 2 3 4 5 6
| for(y=y1;y<y2;y++) { x=x1+(y-y1)*(x2-x1)/(y2-y1); if(x<bufferXmin[y]) bufferXmin[y]=x; if(x>bufferXmax[y]) bufferXmax[y]=x; } |

repeat with for(y=y2;y<y3;y++)

and

for(y=y3;y<y1;y++)

**and now you know all pixels covered :**just do:

1 2 3 4 5 6 7 8 9
| for(y=ymin;y<ymax;ymax) { xmin=bufferXmin[y] xmax=bufferXmax[y] for(x=xmin;x<xmax;x++) { pixel x,y is covered } } |

I think that is the fastest method and it is also simple to implement, I will try to send source code later.

dont forget it is a pseudo-code without basic optimisations

ex:

replace

1 2 3 4 5 6
| for(y=y1;y<y2;y++) { x=x1+(y-y1)*(x2-x1)/(y2-y1); if(x<bufferXmin[y]) bufferXmin[y]=x; if(x>bufferXmax[y]) bufferXmax[y]=x; } |

by somthing like that:

1 2 3 4 5 6 7 8
| coeff1=(x2-x1)/(y2-y1); x=x1 for(y=y1;y<y2;y++) { if(x<bufferXmin[y]) bufferXmin[y]=x; if(x>bufferXmax[y]) bufferXmax[y]=x; x+=coeff1; } |

**EDIT:**note that before doing final stage you can merge multiple polygone together by repeating all steeps except buffer initialisation

Bruno