problems rendering at distances far from origin

Hi,

I am having problems rendering real-time multiple polygon objects at distances very far away w.r.t. where the viewer is in world-space.

I am using a very basic environment setup. No fancy lighting or effects of any sort. All I have is a simple black colored background and two rectangular polygons facing the viewer; one green rectangle positioned behind another red one. I have gl-depth-test enabled.

By real-time I mean I have a very rough code that converts mouse movements to world-space rotation values in perspective projection. So as I move the mouse, the entire view rotates slowly. No extra calculations are performed on the rectangles programatically for any sort of transforms.

The problem happens as the screen is redrawn whenever I move the mouse; the rectangle at the back often appears to be tearing into the rectangle in front. This occurs if the object in front is at distances greater than 10000 units away from the user origin. The rectangles are large enough to be viewable at those distances (1000 x 1000 units)

My simple test involves Immediate-mode drawing, but I have also tested using VBOs, and even textured objects with simple lighting techniques. All giving the same tearing results.

I am using JOGL (OpenGL bindings for Java) and have tested this on 3 different computer systems (all WinXP running the same version of Java6 - in my case) with the same tearing result. I have tried searching the forums but I was unable to find anything similar. I am not sure this is a Java problem because, the code is very straight forward and the situation is very simple. That is why I have posted here.

Any help or advice would be greatly appreciated.

This sound like zfighting :
http://en.wikipedia.org/wiki/Z-fighting

Try to put you near clip plane farther, and your far clip plane nearer.
And make sure you request and get a 24 bit zbuffer, and not 16 bits.
Read this for explanations, old but still mostly relevant :
http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html

Your response has been extremely helpful and my problem is solved. I read the articles you mentioned and realized that I had my near clip at 0.001, which unfortunately is too close to 0.0. Slightly increasing the near clip has solved the bleeding issue. Thank you very much.