Game Development Reference
In-Depth Information
if (y[mid]!=y[min]){
q=(double)(x[mid]-x[min]);
q=(q)?q:EPSILON;
m1=(double)(y[mid]-y[min])/q;
d1=(double)y[mid]-m1*x[mid];
for (i=y[mid];i>y[min];i-){
u=((double)i-d1)/m1; v=((double)i-d2)/m2;
HorzLine(buf, (int)u, (int)v, i);
}
}
count++;
}
}
The function to draw a horizontal line is quite simple. We do some simple
clipping to ensure we stay within memory, get a memory pointer and paint
the pixels one after the other. Notice the class CPolygon has colour
values red, green and blue defined by member variables.
Figure 2.6 Drawing a shaded polygon.
 
Search Nedrilad ::




Custom Search