painting into texture buffer with transparency, overlapping issues


I am trying to draw an interactive line with openGL triangles, which is working fine. But when I try to draw it at opacity <1, ie with some level of alpha transparency, the colors build up as the polygons overlap.

In my old raster-based code, I kept a separate masking buffer which tracked the alpha levels applied in a stroke, so that when the line doubled back on itself, I could control the amount of color on a pixel-level by comparing with the mask.

I am wondering if, using OpenGL, there is something similar I could do? Like use a stencil buffer or some other kind of buffer? I’m not too familiar with various openGL blending states, and it’s already been a lot of trouble just figuring out the correct blend settings for my texture maps with alpha.

Anyone know if what I want is possible in openGL? Basically, I want to draw into the buffer with transparent polygons, and until I say different, drawing more transparent polygons on top of that would only change where the source alpha is greater than the dest alpha. And in that case, I think I’d need a some kind of blend of the target and dest?

Any ideas appreciated!