Weird Antialiasing

I’m having a terrible time trying to figure out antialiasing. And just when I think I have it, I get this . It seems the gl_lines aren’t antialiasing to the thing behind them, but rather to the clear_color background. Here’s what I’m using for initialization:

Any ideas what’s going on?

It’s a Z-buffering problem. OpenGL antialiases by making pixels partially transparent along the edges and blending with the current background. Unfortunately, unless you’ve enabled alpha test, these partially transparent pixels update the depth buffer like any other pixels, so subsequent drawing behind them has no effect on the framebuffer.

This is a standard issue with transparent blending; on current mainstream hardware there’s no solution except to depth-sort your geometry. Which is messy; you might want to reconsider whether antialiasing is all that important to you. (It’s a fair performance hit, and FSAA can reduce the jaggies on cards that can manage it.)