View Full Version : boolean operation, quads and circle.

07-29-2004, 10:55 PM
hi, I need some help with this kind of boolean problem. I have a square (GL_QUADS) built up with four vertices and want to make a hole in the middle of this one.
My idea is to make a circle and then take boolean between the square and the circle, to get a hole where I put the circle.
But I don't know how to do this. If someone can help me I will be very thankful...
I'm a beginner and using Microsoft Visual c++.

07-30-2004, 01:47 AM
Magnuse, this is called constructive geometry (CSG). To do that, you'll need to use the stencil buffer.

This is very simple :
1/ Disable frame buffer writing (glColorMask)
2/ Enable stencil writing
3/ Render your circle
4/ Disable stencil writing, enable stencil test
5/ Render your quad

The next step is to have a cube, and make a hole through it with a cylinder, or half it with a sphere. This uses the same technique, but I'll leave you think about it.


07-30-2004, 04:55 AM
thanx, I've done it now...

08-02-2004, 04:53 AM
As a side note, I'll add that if you're only interested in such boolean operations (i.e. making holes) with "flat surfaces", you may want to have a look at the Tesselator object available in the GLU library.

It won't work for proper CSG though!!! ;)