View Full Version : Pixel Registration Rendering Lines With nVidia GLX

08-29-2002, 12:43 PM
I have an application involving rendering of a 2D image with graphical line overlays. In this application, it is essential that proper pixel registration between the image and the overlays is maintained. I've done this type of work on other systems in the past and did not expect any surprises; however, I'm seeing behavior that I did not expect. Thought I'd run it by other OpenGL folks and see if this is really a bug with nVidia's implementation or simply something I'm overlooking. Here goes:

Basically, I'm seeing that the second vertex specified for each line is not being filled. For example, lets say you have a 2D ortho projection set up and you render the following two horizontal lines:

glVertex2f( (GLfloat) 0.5,
(GLfloat) 0.5 );
glVertex2f{ (GLfloat) 31.5,
(GLfloat) 0.5 );

glVertex2f( (GLfloat) 63.5,
(GLfloat) 0.5 );
glVertex2f{ (GLfloat) 31.5,
(GLfloat) 0.5 );

Personally, I would expect this to result in one continuous horizontal line of 64 pixels in length. Instead, it results in what appears to be two lines seperated by a single non-filled pixel at the location specified as the second end-point for each of the line rendering directives. Again, vertex ordering is important. If you reversed the vertex ordering within the glBegin() and glEnd() statements, you end up with one solid line missing a pixel at each end instead.

Anyway, just wondering if anyone else had noticed this also? If not, perhaps it's simply a problem with my code. If so, is this the intended behavior or is this counter to the intended behavior. At this point, I'm leaning toward this being a bug in the OpenGL implementation; however, I'm open to enlightenment as to the error of my ways. http://www.opengl.org/discussion_boards/ubb/smile.gif


Moshe Nissim
08-30-2002, 11:52 PM
I had the impression that nVidia uses polygon primitive to implement lines. In other words, there is no dedicated line rasterization engine. Such 'tanslation' can lead to many artefacts. I am not 100% sure about this, but you can experiment with lines with >1 linewidth, and see what I mean...

08-31-2002, 06:54 PM
If I get it right do the line ends in the middle of a pixel. That pixel is only 50% covered. Should this pixel be filled? Both solutions gives a "0.5 pixel error".

Perhaps do you think of antialiasing?

09-01-2002, 10:14 AM
The diamond exit rule.

"A diamond-shaped area exists within each pixel. A pixel is rasterized by a line only if the mathematical definition of that line exits the diamond inscribed within that pixel."

I'd say that the last pixel is not being rasterized because someone interpreted that as "the line is no more exiting this last point"...

Rob Fletcher
09-02-2002, 07:05 AM
Check this thread as supplied in a similar discussion in the adv forum