[gl2ps] Depth issues in GL2PS

David Lonie david.lonie at kitware.com
Fri Oct 12 23:23:54 CEST 2012


Hi list,

I'm using GL2PS to export a scene that is drawn in 2D, e.g. at
constant Z in OpenGL.

I've verified that z is the same for all vertices in the feedback
buffer by watching gl2psGetVertex. In all cases, p[2] = 0.5.

However, by the time the primitives are sorted, some of the vertices
are at different depths. Most are at 0.0, but a few are at -20.0.

This wasn't an issue for pure 2D scenes -- I just turned off sorting,
and the primitives were rendered in painter order and everything
worked great. Now we're trying to mix 2D painter rendering with 3D
geometry, so we need to sort these guys, and the z=-20 vertices are
throwing off the renderings.

Any idea why some vertices are being transformed differently? I don't
mind debugging/fixing this, but I'd greatly appreciate some pointers
to likely culprits in the code.

Somewhat related: I've had to add a stable sorting method to preserve
the painter order for the 2D primitives. I'll send a patch for this
once I get this other issue sorted out.

Thanks in advance,

Dave