Opengl pixel perfect 2D drawing

In OpenGL, lines are rasterized using the “Diamond Exit” rule. This is almost the same as saying that the end coordinate is exclusive, but not quite…

This is what the OpenGL spec has to say:
http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node47.html

Also have a look at the OpenGL FAQ, http://www.opengl.org/archives/resources/faq/technical/rasterization.htm, item “14.090 How do I obtain exact pixelization of lines?”. It says “The OpenGL specification allows for a wide range of line rendering hardware, so exact pixelization may not be possible at all.”

Many will argue that you should not use lines in OpenGL at all. Their behaviour is based on how ancient SGI hardware worked, not on what makes sense. (And lines with widths >1 are nearly impossible to use in a way that looks good!)

Leave a Comment