///////////////////////////////////
void SetTransparentColor(
LPDIRECTDRAWSURFACE lpDDS,
int rgbRed, int rgbGreen, int rgbBlue )
{
DDCOLORKEY ddColorKey;
ddColorKey.dwColorSpaceLowValue =
RGB(rgbRed, rgbGreen, rgbBlue);
ddColorKey.dwColorSpaceHighValue =
RGB(rgbRed, rgbGreen, rgbBlue);
lpDDS->SetColorKey( DDCKEY_SRCBLT,
&ddColorKey);
}
///////////////////////////////////
I call this function (after I do all my DirectDraw initializations) like this:
SetTransparentColor( lpddsback, 0,0,0 );
During the game loop, I blit with the following syntax:
lpddsback->Blt (&destRect,lpddsOne,&srcRect,NULL,NULL);
The code builds fine, but that sprites in the game are not transparent, even though the background of my source bitmap is black.
I think it might be that I have to use the DDBLT_KEYSRC dwFlag to do this, like this:
lpddsback->Blt (&destRect,lpddsOne,&srcRect,DDBLT_KEYSRC,NULL);
But when I use this the sprite just doesn't show up at all. Does anybody know how to fix this?