PDA

View Full Version : How to erase part of the drawn objects?



earth_walker
07-26-2003, 04:37 AM
Hi! I draw a lot of objects in the viewport, and then if I want to erase one of them but don't want to clear the whole buffer and draw everything else again. Can I do that?
Thank you!

nexusone
07-26-2003, 05:10 AM
No, not that I know of.


Originally posted by earth_walker:
Hi! I draw a lot of objects in the viewport, and then if I want to erase one of them but don't want to clear the whole buffer and draw everything else again. Can I do that?
Thank you!

yaro_dup1
07-26-2003, 05:13 AM
You have to draw everything again without that polygon. This is only the way.

[This message has been edited by glYaro (edited 07-26-2003).]

07-26-2003, 10:50 AM
You can erase a selected object using the stencil buffer. When you draw the selected object you call glStencilFunc(GL_ALWAYS, 1, 1) and glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE). And when you want to erase it you call to glStencilFunc(GL_EQUAL, 1, 1) and glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP) and simply draw a big black rectangle with GL_DEPTH_TEST off. This will erase everything in your object's outline.

Omaha
07-27-2003, 02:54 AM
Do you think this would be more versatile for the first step?

glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);

Otherwise after that step you will have the complete silouette of the object in the stencil buffer. If parts of the object were occluded by other objects during the depth test you probably don't want stencil updating to occur.

[This message has been edited by Omaha (edited 07-27-2003).]

earth_walker
07-27-2003, 03:18 AM
Thank you! I will go to read the stencil part of OpenGL reference.