Line drawing.

Is there a way to do pixel exact line drawing in opengl?
Beside drawing images, I need to do simple things like drawing points, lines, rectangles, circles etc for a GUI. I once tested it with a 45 degree diagonal line (with glBegin(GL_LINES)), but when I resized the window, the line changed a bit, which will look very ugly in a GUI.

use an ortho projection matrix with (0,0) mapping as the bottom left of the screen and (screenwidth,screenheight) mapping as the top right.
your lines will look better if u use antialiasing as well