OpenGl Occlusion

The question is I want to draw three squares, draw a first one, then draw a second one, the second one should be overlaping the first square, then draw a third one with black masking zone. The third one occludes the portions of first and second. But Actually I want to onclude the first one only. I want to draw the third one with masking zone, occluding the first one but I should be able to see second one. I have the co-oridnates to specify the overlaping

The second square should be transparent eventhough I have a masking zone around the third square.

In Iris gl, I could use mapcolor to create my own color map to draw it in color index mode. But OpenGL don’t have an equivalent to mapcolor. In Iris gl, I could draw the hird square with black masking zone, but not occluding second one.

I don’t want to use glut and overlay. If any one has a sample code please post it or email to me

Masking ? Try using stencil, alpha test, depth test.
To emulate 1 bit transparency (I guess you used it in color index mode), you have to generate an alpha channel.
Can you make an image, to explain better your problem ? It is very confusing…

And by the way, this is not ‘advanced’ as you are just beginning in OpenGL.

Thanks for the reply, I posted this same question with code on the beginner section, I did’t get an answer. Would you please check the message “OpenGL color map mode” in the beginners section and help me.

thanks.
nk