title: OpenGL - Question about the usage of glDepthMask
body: <p>I have rendered an objectA in a scene as follows. The scene has many other objects too.</p>
  
  <pre><code>void Draw()
  {    
      if( glIsList( displayListID ) )
      {
          glPushAttrib( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_ENABLE_BIT );
  
          glEnable( GL_BLEND );
          glEnable( GL_DEPTH_TEST );
          //glDepthMask( GL_FALSE );
          glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
  
          glEnable( GL_LINE_SMOOTH );
          glEnable( GL_POINT_SMOOTH );
          glEnable( GL_POLYGON_SMOOTH );
  
          glMatrixMode( GL_MODELVIEW ); 
  
          color.setAlpha(alpha); // set alpha transparent of this objectA
          glCallList( displayListID );
  
          //glDepthMask( GL_TRUE );
          glDisable( GL_BLEND );  
  
          glPopAttrib();
      }
  }
  </code></pre>
  
  <p>Now here is the problem,</p>
  
  <p>As shown, I comment out two lines
  //glDepthMask( GL_FALSE );
  //glDepthMask( GL_TRUE );</p>
  
  <p>the scene renders the objectA and other objects correctly in depth. However,
  the modification of the objectA alpha doesn't work anymore (i.e. color.setAlpha(alpha) ).</p>
  
  <p>If I uncomment the above two lines, then alpha modification is back to work. However, the depth rendering is NOT correct. In other words, sometimes, the objectA should be behind other objects but it looks like the objectA is in front of all objects.</p>
  
  <p>How do I fix this problem?</p>
  
  <p>Thank you</p>