Stencil buffer

What i want to do is to make a rectangular box and be able to “cut” a cylinder out from 1/2 of it (i.e. the outer edge of the cylinder will be in between both sides of the box, makeing the center along 1 edge of it) so that i can see behind and in front of the cylinder, but everything where the cylinder is gets cut out. Well, i tried using the stencil buffer, but my book only covers about 1 page on it, and i havent been able to find any tutorials on it. I have gotten it so that everything in and behind the cylinder is cut out, but i want to keep the stuff behind it visible. Is this the way or is there a better way to do this?

Hi,

Try on this website to get the stecil buffer example.
http://myopendemo.hypermart.net/opengl3.htm

thx for the tutorial, it really helped a lot, but let me refrase my question…
basically what i am doing is creating a pool table. now, the side pockets are the only thing left that i dont know how to do. if you look at a pool table, it has a half indented circle in the side wall where the pocket is, so i want to recreate this. So how should I go about doing this?

If u want to clip against a 2D region or a 3D space, u can try glClipPlane

  • Chetan

Ok, but remeber that its basically a half clyinder I want to clip out (it doesnt matter if its a half or a full cylinder, which would be easier neways), so it is 3d. I guess I could clip circles out along the Z axis making it like a cylinder, but I would think this would be very ineffecient.