GL_LINE_STIPPLE causes inaccuracy

When I use GL_LINE_STIPPLE, the line is horizontally offset by one pixel. I am using a GEForce 4 MX, a pretty common card.

Without stipple:

With stipple:

did u try first offsetting the view by by 0.375 0.375
else u could ditch stipple and draw the line with a stippiled texture, or if u use glsl etc u wouldnt need a texture

Why would I want to offset the view by 0.375?

Okay, I see why you asked that, but why would stippled lines be behaving differently from non-stippled lines? If they just both worked the same, it would be fine.

Maybe I’m weird but they look fine to me.

-SirKnight

Look carefully. The stippled line does not line up to the grid.

Originally posted by halo:
When I use GL_LINE_STIPPLE, the line is horizontally offset by one pixel. I am using a GEForce 4 MX, a pretty common card.

Interesting. That card probably doesn’t support stippling in hardware (or if it supports it, it’s disabled by the driver and only enabled on the Quadro counterpart).

That means that the stippled lines are transformed in software (at least you need to transform then in sw to apply the proper stipple pattern) and then rendered using transformed textured lines or fully rendered in software.

Anyhow, my hunch is that the software transformation is giving slightly different results from the hardware transformation and causing that pixel mismatch.

As some other people have said, you can try rendering textured lines, but note that it’s very tricky to get proper (OpenGL conformant) stippling with textured lines.

It’s interesting (or rather unfortunate) that OpenGL doesn’t require invariance wrt. stippling.