Stencil and depth buffer clearing

I have the following problem:

I’m drawing a scene with a stencil. After that I’m drawing a different scene into the stencil.

My problem is that the first scene contains translucent objects which have to be drawn over both the original scene and the stencil with depth buffer information of the original scene.

Is there a way to clear the depth buffer only in the current stencil area because I don’t want to redraw the first scene?

You seem to have 2 distinct problems here, let’s deal with the easiest first:

  1. clearing the depth buffer only in the current stencil area :

glStencilMask(0);
glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
//glBufferMask(GL_TRUE); // activated by default

< or use glClear(GL_DEPTH_BUFFER_BIT); I am not sure>

glStencilMask(0xFFFFFFFF);
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);

  1. first scene contains translucent objects which have to be drawn over both the original scene and the stencil with depth buffer information of the original scene.

mmh, I am not really sure to undersdant what you mean. A picture may help ?
And beware of substractive transparency, order does matter.

[This message has been edited by ZbuffeR (edited 02-03-2004).]

Originally posted by ZbuffeR:
[b]You seem to have 2 distinct problems here, let’s deal with the easiest first:

  1. clearing the depth buffer only in the current stencil area :

[quote]

glStencilMask(0);
glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
//glBufferMask(GL_TRUE); // activated by default

< or use glClear(GL_DEPTH_BUFFER_BIT); I am not sure>

glStencilMask(0xFFFFFFFF);
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);

  1. first scene contains translucent objects which have to be drawn over both the original scene and the stencil with depth buffer information of the original scene.

mmh, I am not really sure to undersdant what you mean. A picture may help ?
And beware of substractive transparency, order does matter.

[This message has been edited by ZbuffeR (edited 02-03-2004).][/b][/QUOTE]

It’s supposed to be some kind of holographic monitor. So the translucent objects in front of this monitor must be drawn after its contents. That’s all.
I don’t have pictures because I didn’t get it to work yet. I’ll try your suggestion. I hope it helps.