Depth buffer resolution probs with orthographic projection

G’day,

I am having a few depth buffer resolution problems. Not sure if it’s my fault or just expected behaviour. Here is a screeny:


http://img251.imageshack.us/img251/5294/untitledwi8.th.png

You can see on the edges where the hidden lines are shown.

I initialise my render device like this:


        GLCapabilities glc = new GLCapabilities();
        glc.setDoubleBuffered(true);
        glc.setStencilBits(0);
        glc.setDepthBits(32);
        myGLPanel = new GLJPanel(glc);
        myGLPanel.setOpaque(true);
        myGLPanel.setDoubleBuffered(true);

I draw the lines (black) and the elements (green) separately, and since they are overlapped I set glDepthRange() like this for lines:


gl.glDepthRange(0.0f, 0.995f); //draw lines over polygons

and like this for elements


gl.glDepthRange(0.005f, 1.0f); //draw polygons under lines

The only other thing I can think of that affects the resolution is the orthographic projection, which I do like this:


        //orthographic projection
        gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();

        gl.glOrtho(-glWidth, glWidth, -glHeight, glHeight, 
                   -vertices.modelRadius * mouseHandler.zoomScale, 
                    vertices.modelRadius * mouseHandler.zoomScale);

The zooming with the mouse is performed on the projection matrix.

If anyone can spot anything glaringly wrong with this approach, I would welcome any suggestions.

Cheers,

Pinky

When I do the same thing - draw an object with a visible wireframe - I use a call to glPolygonOffset( 1, 1 ) and glEnable(GL.GL_POLYGON_OFFSET_FILL) to push the solid filled polygons back a touch. Turn it off again with a call to glDisable(GL.GL_POLYGON_OFFSET_FILL).
It works for me:

http://www.google.co.uk/base_media?q=hand-3554722602584282077&size=6

spot on there bleb. The solid fill is depth fighting, glPolygonOffset should fix that nicely.

DP