PDA

View Full Version : alpha blending



07-09-2002, 12:48 PM
i know that this question pops up numerous times, but i really am stumped.

i have a method that draws a chain (3 torii). i need it to be drawn both opaque and translucent. this chain moves around, and i wanted to draw the beginning and ending states of my animation translucent, while the current frame of where the chain is is drawn opaque.

so my paintGL is essentially (half pseudocode)

paintGL()
{
drawChain();
drawTranslucentChain( beginningTime );
drawTranslucentChain( endTime );
}

drawChain()
{
uses only Color3f() statements
}

drawTranslucentChain()
{
glPushAttrib( GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT | GL_DEPTH_BUFFER_BIT );

glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

// set alpha bit
glColor4d( 0., 0., 0., 0.1 );
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE );
drawChain();
glPopAttrib();
}

for some reason, though, the ending and beginning chains are drawn FULL alpha! why is this, even though the ColorMask is turned on?

Much thanks,
Jon

DFrey
07-09-2002, 02:21 PM
Ok, your use of glColorMask most likely isn't needed at all from your description of what you want. And second of all, your transparent function simply uses the nontransparent function to draw the torii, and it uses the glColor3f function, which itself calls into use an implicit value of 1 for the alpha component.