PDA

View Full Version : Exclude a 2D polygon from a 2D polygon



ame_nguyenanhtai
06-16-2008, 09:10 PM
Dear all,

Please tell me if you know a good algorithm for excluding a 2D polygon from a 2D polygon. I would like to appreciate your help

tirsac
06-17-2008, 05:00 PM
Depending upon your requirements, I can make two suggestions.

1. To draw polygon A with polygon B subtracted, first draw polygon B with the depth and color buffers disabled but with the stencil buffer enabled and to write a value of 1 to the stencil buffer. Then draw polygon A where the stencil buffer is not 1. Make sure the stencil buffer is cleared to zero each frame. If you need to reuse the stencil buffer for drawing other geometry, you need to set the stencil buffer back to zero by redrawing polygon B with a stencil value of zero.

2. Use the gluTess* functions to create a polygon that is the difference of the two polygons.

ame_nguyenanhtai
06-25-2008, 04:16 AM
Thanks for your help