How to not show something in back of object

Hi, I have a Sphere that I created with
glutSolidSphere, and on that sphere there is some cyllinders that I put on it, however when I rotate the entire object the Cylinders show up at all times, even when they should be “behind” the sphere, you can see them through the sphere…How do I stop it from doing this?

I tried

and that didn’t seem to do anything…

Thanks for any help.

Did you set up your Depth Buffer correctly?


and of course, make sure you’ve allocated bits to it via the pixel format call or in case of GLUT, with the GLUT_DEPTH call in your glutInitDisplayMode()

Hi I didn’t have the GLUT_DEPTH in there, but I had everytyhing else…
now that I added GLUT_DEPTH my Linux is giving me the same problems as the Windows one is.

its probably some dumb mistake, I just cant find it.

Nevermind, I figured it out, I was not
I fixed that so it works now.