Game Development Reference
In-Depth Information
Drawing an outline polygon
We can use this new class to draw an outline polygon simply by
connecting all the points in the polygon. Once the polygon has been
transformed to screen coordinates using the techniques from the previous
chapter, this involves just this simple code. Note that, once a polygon has
been transformed, the screen coordinates are stored in the sx and sy
members of the POINT3D structure points.
void CPolygon::DrawOutline(CCanvas &buf){
if (numverts<3) return;
for (int i=0;i<numverts-1;i++){
buf.DrawLine(pts[i].sx, pts[i].sy, pts[i+1].sx,
//Finally join the last point to the first
buf.DrawLine(pts[numverts-1].sx, pts[numverts-1].sy,
pts[0].sx, pts[0].sy,col);
Figure 2.4 A flat coloured polygon.
Search Nedrilad ::

Custom Search