I want a "FillPoly algorithm"

I want to implement Gourad Shading in mi 3D Apps, but I need an algorithm
for draw and fill algorithm.

Can anybody helpme?