Render display list at half-alpha...

I have some existing code that renders a display list. I would like to render the display list at half-alpha, so that it is ghosted behind some other data. Is this possible, or do I need to redo the display list to use half-alpha?

I was hoping if the display list used glColor3f, then I could set the alpha to 0.5 beforehand (using glColor4f()), and the display list would leave the alpha alone, but this doesn’t seem to work. I also looked at glBlendFunc() to see if there was a way to work with SRC_ALPHA at 0.5, but this doesn’t seem to be the case.

The display list also includes anti-aliased lines, so this complicates things a little further.

Any ideas?

glColor3f does set the alpha to 1, read the doc :
“glColor3 variants specify new red, green, and blue values explicitly and set the current alpha value to 1.0 (full intensity) implicitly”

A way to not change the display list would be to send a uniform (out of display list) to GLSL vertex shader, which is only updated as alpha changes. The vertex shader will multiply current color with this uniform at runtime.

If you never change the color in the display list, that really shouldn’t be a problem:

glColor4f( r, g, b, a );
glNewList( list, GL_COMPILE_AND_EXECUTE );
glColor4f( r, g, b, 0.5f*a );
glCallList( list );

Another possibility might be display list nesting: if you call glCallList() while compiling another list, re-compiling the nested list will also change the behavior of the calling list. So you could use nested lists for changing colors and just recompile those. Still that would really be an OpenGL 1’y way of doing it. Using GLSL and a uniform looks like a better idea if you’re OK with using shaders.