Coplanar line and polygon

I need draw a line in a polygon (a rectangle for example), but it must be continuously on one side and dashed the other. But there is a problem because they are coplanar.
Has anyone had any similar problem?

PS: I resolve a similar problem and with two polygons, using offset and cull face, but that solution is not feasible for lines.

Thank you all!

Be sure to check the wiki for commonly asked questions…

Hope it helps.

Thanks for the answer, but it does not helped me completely.
I did what I wanted using stencil buffer, but now I have other problem: poor performance.
Someone had another solution?