Drawing to depth buffer only.
Your code should look like :
glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); //disable write to color-buffer glDepthMask(GL_TRUE); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); // or whatever //render everything glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); //enable write to color buffer
For resetting the alpha channel only :
glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE); //only write to alpha glDisable (GL_DEPTH_TEST); glDepthMask(GL_FALSE); //Render a full-screen quad with alpha=whatever you want