Jump to content

  • Log In with Google      Sign In   
  • Create Account


SetColorKey problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 CoolMike   Members   -  Reputation: 122

Like
Likes
Like

Posted 29 October 1999 - 02:18 AM

I am trying to implement transparency into my 16-bit DirectDraw game engine using color keying. I use the following function to set transparency:

///////////////////////////////////
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?


Sponsor:

#2 Machaira   Moderators   -  Reputation: 1028

Like
Likes
Like

Posted 29 October 1999 - 02:18 AM

Normally you set the color key on your sprite bitmaps, not your backbuffer as you appear to be doing. Just change your line

SetTransparentColor( lpddsback, 0,0,0 );

to whatever plain off screen surfaces you have and you should be fine.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS