View Full Version : cutting a hole
12-10-2007, 03:43 AM
I draw a cylinder on the screen and cut this cylinder from its center with a smaller diameter cylinder. I mean I am trying to draw a pipe.
The cut is not blind (I mean the length of the small diamater cylinder is bigger than the other one).
I succeded to cut the cylinder using stencil buffer.
However, the back surface of the cylinder is still visible although it is not a blind hole.
I am trying to see the background from the hole.
I again used stencil buffer to mark this zone and I think I succeded.
However, I don't know how to make the background visible again on that zone.
Would you please help me?
12-10-2007, 05:26 AM
I think, what you are missing is the save&restore depth part of that presentation.
12-10-2007, 06:24 AM
Thank you Michael for the document.
However, I don't know how to save the background info.
I used glClearColor and glClearDepth to set the depth buffer and color for my background. But, I don't know how I can save this info.
I succesfully marked the zone that will be completely deleted (and background will be shown at that zone)using stencil buffers.
I want to learn if I have to use glClearColor and glClearDepth again for that zone (actually I tried but it didnt work) or I should draw something there again at zfar with the same color of background.
12-10-2007, 09:17 AM
Yes, I am working on that and try to improve my question.
Now, I am almost sure I marked the zone correctly (stencil buffer) where I will delete and where the background will be shown.
After this stencil test, I tried
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
It doesnt work.
When I tried this line, everything disappeared from the screen, only the background is displayed.
I just want to learn if there is a way to clear only the marked zone and to display the background color in that zone.
12-15-2007, 05:36 AM
Hey there... well, the stencil buffer does not affect the glClear operation, you will not be able to do it that way. What you can do is either grabbing the depth and writing it back, drawing your CSG object as the last object, or writing a new face at max-distance in your marked stencil-area (glDepthFunc( GL_GREATER) with enabled stencil). In all cases, the CSG operation needs to set the z-values even on pixels which are not written to later-on. As i lost pace with upcoming pixel shaders, i don't know how much one could do with the underlying buffers manually.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.