PDA

View Full Version : Line rasterization



Belgrad
10-04-2002, 09:16 AM
Line segment rasterization ignores last pixel. How to explicitly force OpenGL to draw this pixel?

Gavin
10-04-2002, 09:39 AM
Really? draw a point at the end or make your line one pixel longer.

Belgrad
10-04-2002, 10:47 PM
One another thing: drawing accuracy for points and line segments are different -

code like this:

// all in orthographic projection

glBegin( GL_LINES );
glVertex3d( x0, y0, depth2 );
glVertex3d( x, y, depth2 );
glEnd();

glBegin( GL_POINTS );
glVertex3d( x, y, depth1 );
glEnd();

produces a line segment and a point that lies NEAR the segment's end (positioning error is near float type precision limit)

Is it possible?

Belgrad
10-04-2002, 11:09 PM
Problems left with OpenGL 1.1 libraries downloaded from M$. Funny though! Where's the root of all evil? in Win2k OpenGL libraries, NVidia drivers (I have ASUS GF2MX400) or... somewhere else?

Gavin
10-05-2002, 12:55 AM
I will try it in a bit when I have time to see if I get the same...

Bob
10-05-2002, 01:12 AM
I think it's pixel center problems. The coordinate (x,y) may be projected exactly between two or four pixels, and lines and poins may round in different directions, therefore hitting different pixels when drawn.

Gavin
10-05-2002, 03:03 AM
Mine seemed ok using

glBegin( GL_LINES );
glVertex3d( 0, 0, 0 );
glVertex3d( 50, 50, 0 );
glEnd();

glBegin( GL_POINTS );
glVertex3d( 50, 50, 0);
glEnd();

with a perpixel ortho display set up.

Gavin
10-05-2002, 03:05 AM
But as Bob says try offsetting so that you are drawing from a pixel rather than the crossroads of 4 or whatever. There have been a few posts on this for 2d displays/raster coords

Belgrad
10-05-2002, 03:19 AM
Nope, offsetting doesn't cure this problem.

Omaha
10-06-2002, 11:27 AM
Yes, let's blame Microsoft for everything. *rolls eyes* Actually, it's no ones fault except the developers for trying to optimize their drivers; you'll notice that the OpenGL specification does not require that all implementations have pixel-perfect results to the same rasterization call, so your line may appear differently on different setups.

what
10-07-2002, 02:02 PM
GL dosen't draw the bottom and left edges of polys so that if two polys share an edge only one of the polys will draw the shared pixels on the edge. same goes for lines left end as well.