[gl2ps] Depth issues in GL2PS

David Lonie david.lonie at kitware.com
Mon Oct 15 15:24:53 CEST 2012


On Sun, Oct 14, 2012 at 9:22 AM, Christophe Geuzaine
<cgeuzaine at ulg.ac.be> wrote:
> On 12 Oct 2012, at 23:23, David Lonie <david.lonie at kitware.com> wrote:
>> 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.
>
> Hmm, weird. I would start by debugging what's actually in the feedback buffer (gl2psParseFeedbackBuffer) and see if the error is already there.

Turns out that the line offset option was on -- my mistake. Everything
looks good once that option is disabled. The stable sort isn't needed
anymore, simple sort is producing the correct ordering, so I'll just
revert my patch for that.

Thanks,

Dave