Incomplete triangles problem

Hello everyone.
I’m having a nasty incomplete triangle / flickering issue.

I’m using Jogl (beta1) with j2se 5.0 (and testing on Windows). I’m not into 3D professionally, just a coder in a demoscene group back from retirement and preparing a release for next summer…
So I made a pure Java 3D engine recently (this is my 2nd 3D engine, the first one was made in OGL / C++ a long time ago) and i’m currently testing it. Jogl is completely hidden behind the abstraction.

So if i make my own objects using my abstraction objects and run, this works well (here using multitexturing and lighting)

http://img77.imageshack.us/img77/6906/multitex0fr.jpg

Now i have (re)written my old C++ 3ds Max export plugin and it’s exporting the scenes perfectly, however, upon rendering, I get incomplete triangles !!! There is only a 12-triangle box and a positional light here.

http://img57.imageshack.us/img57/5796/joglflicker1li.png

I can hardly show you some running code example since i have 218 classes and interfaces and useless things.
To be precise, there are 2 threads : the main one in which i’m instanciating and preparing all the stuff, amongst which there is the creation of the GLCanvas (that is later included into a JFrame), and another very simple one doing very basically :


  public void run()
  {
      while(running) {
          graphManager.produceFrame(currentTime);
        }
        yield();
      }
  }

produceFrame(time) only saves the time somewhere, computes the framerate and calls drawable.display().

And the GLEventListener#display(GLAutoDrawable) draws all the scene based on the previously saved time and calls glFlush().

Well i tried with or without the AutoSwapBufferMode and a manual swapBuffer() after the display(), i really tried lots of other things too (that’s because I don’t know anything else to try i’m writing here now), but the incomplete triangles remain. If the object moves, the incomplete parts change of location, have different shapes, are more or less big, and when done 50 times/second, it looks like an Aphex Twin videoclip :wink:

http://img484.imageshack.us/img484/2377/joglflicker24uq.png

However, i noticed that if i put the object twice in the same position/rotation, then the exact same parts are screwing up.

I thought it was because of my second thread that must be calling drawable.display() like 500 times / second because it has nothing else to do and it could disturb everything but even with a sleep(1000) in the loop, the issue remains !!!

So if you guys got that kind of problem i’d be extremely grateful to you to explain me.
Thanks a lot.

fabien

Do you have a z-buffer and have you enabled it (gl.glEnable(GL.GL_DEPTH_TEST))? Have you looked at the basic Gears demo to see how it sets up and uses the z-buffer?

You might also be seeing z-fighting if your near clip plane is too close and the far clip plane too far away from the camera.

Yeah indeed you got a point.

I’m using these :


    gl.glDepthMask(true);
    gl.glEnable(GL.GL_DEPTH_TEST);
    gl.glDepthFunc(GL.GL_LEQUAL);
    gl.glClearDepth(1.0f);

Which can’t lead to mistakes,

BUT my perspective is

glu.gluPerspective(45.f, 1.3f, 0.001f, 10000.f);

And 0.001 is way too close for the old lady… 0.01f will obviously make it work…and it does !

THANKS !!