Polygon rendering problem

In the attached zip file, there are two png files. One showing how the polygon is being rendered now and another showing how it should be rendered.

Basically, polygon is rendered by displaying the back color also. which I want to eliminate. In poly_red.png file, the part of polygon marked with red should not be displayed. What is the problem here in poly.png?

Thanks

I know there is a saying “a picture is worth a thousand words” but not when you want code debugged. At a guess you look like you need to use stencil buffers. Have a look at the red book for rendering polygons