Creating invisible object

Hi,

I would like to create a totally “invisible” object (can be a simple one, like a “gluCylinder”). The viewer would notice the object when it is behind or collide with another object - example, if a “glutSolidCube” is behind my “invisible gluCylinder”, the cube would be partially occluded by the cylinder (we would see the background on the occluded area).

How can I do that? I’ve tried to use glColorMask, so I could hide the cylinder , but the mask affected the whole frame instead of only the cylinder (maybe I’m not using it correctly, is there a way of doing it only for one (or a few) objects?). I don’t think transparency would work for me, because I’d see the occluded part of the cube, for instance.

Can you help?

Thanks in advance

Well, because you didn’t reset the color mask after you’ve drawn the invisible cylinder. Set glColorMask to all false before drawing the invisible cylinder then reset it to all true.

Thanks, it worked.
I was putting false only on the color I was drawing the object and reseting it. I should have put everything false as you suggested.