title: OpenGL: How to determine if a 3D (rendered) point is occluded by other 3D (rendered) primitives in front of it?
body: <p>In my OpenGL program, I am doing the following in sequence:</p>
  
  <pre><code>// Drawing filled polyhedrons
  // Drawing points using GL_POINTS
  // Displaying information for each above point beside it
  </code></pre>
  
  <p>For displaying the point information (say a point identifier/number), I convert the 3D coordinates of the point to 2D window coordinates using <a href="http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/glu/project.html" rel="nofollow noreferrer"><strong>gluProject</strong></a>(). I write the point identifier at that 2D window location using <a href="http://www.opengl.org/sdk/docs/man/xhtml/glRasterPos.xml" rel="nofollow noreferrer"><strong>glRasterPos</strong></a>() and 2D character rendering code.</p>
  
  <p>When a rendered point is occluded by another primitive, it is automatically <em>not</em> displayed due to automatic occlusion test and depth test that happens in the OpenGL pipeline. However, my point identifier text is displayed beside the point, even when it is occluded since I do not get this occlusion information.</p>
  
  <p>How to determine if a 3D (rendered) point is occluded by other 3D (rendered) primitives in front of it? Or is there a better way to display the point information text beside it <em>only</em> when it is not occluded?</p>
  
  <p>Note: I am aware of the methods that require an extra rendering pass. I feel that those are expensive for my purpose.</p>