PDA

View Full Version : GL_LINE_STIPPLE causes inaccuracy



halo
02-08-2005, 06:55 AM
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:
http://www.leadwerks.com/stipple1.jpg

With stipple:
http://www.leadwerks.com/stipple2.jpg

zed
02-08-2005, 10:10 AM
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

halo
02-08-2005, 12:04 PM
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.

SirKnight
02-08-2005, 12:54 PM
Maybe I'm weird but they look fine to me.

-SirKnight

halo
02-08-2005, 12:56 PM
Look carefully. The stippled line does not line up to the grid.

evanGLizr
02-08-2005, 05:59 PM
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.