I have a problem rendering horizontal and vertical lines when multiple sample buffers are being used. The problem is that even when I specify a line width of 1 and colour of black, these lines are drawn thicker and greyer than I had hoped for i.e. they are not crisp, thin lines but fuzz, greyish lines. If I disable multi-sampling then these lines are rendered as I want but then angled lines are rendered with a very jagged appearance (also undesirable).
Is there a way to render horizontal and vertical lines crisply and with a fine, dark appearance and angled lines with minimal jaggies in the same context at the same time? Perhaps there is a way to disable multi-sampling for horizontal/vertical ines but enable it for angled lines? Some other technique perhaps?
glDisable(GL_MULTISAMPLE) should produce single-sample rendering in a multisample buffer, so you could do that when you know the lines are exactly horizontal or vertical. However this is known not to work on some older hardware.
I tried GL_LINE_SMOOTH but the results were not what I wanted in that the horizontal and vertical lines are rendered thicker than desired although their colour looks better (i.e. darker when appropriate).
The only way I can see to draw crisp, thin horizontal and vertical lines is to disable multisampling and line smoothing.
You need to ensure that your lines fall on whole pixels. If they fall between two pixels, antialiasing will (correctly) smooth the line and make it appear thicker.
In short, enable FSAA or GL_LINE_SMOOTH and align the ends of your lines to the pixel grid before rendering.
OK, sounds good but being a newbie at this, how do I “align the ends of your lines to the pixel grid”? I don’t really like the idea of enabling/disabilg FSAA on-the-fly so a better solution would be ideal.