Suppose you have a rectangular face and two points one in front of it one behind. The two point are labeled with a 2D text saying front and back. You always see both the labels because they are drawn using glDrawPixels().
We want to avoid drawing the label for the hidden point.
The first approach suggested on this forum was to draw points only, get the fragments depth with the glReadPixel() then draw the complete scene and read again fragments depth. Comparing the former depths with the latter ones you can easily sort out the labels to be drawn.
This is fairly easy to understand and implement but if fails in our case because the points are on the model faces so in many cases visible labels flickers do to depth values almost identical.
How can we fix this?