Direct Draw 7 color keying?

This is a discussion on Direct Draw 7 color keying? within the Game Programming forums, part of the General Programming Boards category; does anyone have working transparency code for DD7? I'm using DX8.1 (but DD7) on WinXP and here is my basic ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    403

    Direct Draw 7 color keying?

    does anyone have working transparency code for DD7? I'm using DX8.1 (but DD7) on WinXP and here is my basic code:

    PHP Code:
    void cozSprite::Draw(int frameint xint yLPDIRECTDRAWSURFACE7 dest)
    {
        
    RECT destRect;

        
    //horizontal extent
        
    destRect.left x;
        
    destRect.right destRect.left Width;
        
        
    //vertical extent
        
    destRect.top y;
        
    destRect.bottom y+Height;

        
    //blit it
        
    dest->Blt(&destRectImage[frame], &srcRectDDBLT_KEYSRC|DDBLT_WAIT, &ddbltfx);
    //error reported is that there are invalid parameters, commenting out DDBLT_KEYSRC fixes this

    Image is an array of LPDIRECTDRAWSURFACE7-s, and here is the function to create them:

    PHP Code:
    void cozSprite::CreateSurfaces()
    {
        
    DDCOLORKEY ddck;

        for(
    int i 0Framesi++)
            
    Image[i] = DDBase.CreateOffscreenSurface(Width,Height);
        
        
    //ddck.dwColorSpaceHighValue = ddck.dwColorSpaceLowValue = ColorMatch(RGB(254,0,254));
                    
    ddck.dwColorSpaceHighValue ddck.dwColorSpaceLowValue = (DWORD)RGB(254,0,254);

        for(
    int i 0Framesi++)
            
    Image[i]->SetColorKey(DDCKEY_SRCBLT, &ddck);

    All that happens is that nothing is drawn, and when i check my error messages on all of these functions setcolorkey has no errors, nor does anything else in my entire program (at least related in any way to drawing code), but I do get a DDERR_INVALIDPARAMS on the Blt() call.

    I would really appreciate any help that anyone can give me, I'm really having a hard time with this.

  2. #2
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    I just use:
    Code:
    //in my initialization
    DDCOLORKEY ddck;
    ddck.dwColorSpaceLowValue=RGB(0,0,0);
    ddck.dwColorSpaceHighValue=RGB(0,0,0);
    lpddsTile->SetColorKey(DDCKEY_SRCBLT,&ddck);
    
    //in my game loop
    
    //if using BltFast (which I prefer)
    lpddsBack->BltFast(rcTrp.left,rcTrp.top,lpddsTile,&rcTrpAnim,DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY);
    
    //if using Blt
    lpddsBack->Blt(&rcTrp,lpddsTile,&rcTrpAnim,DDBLT_WAIT | DDBLT_KEYSRC, NULL);
    The only thing I noticed is that you're passing a pointer to a DD BltFx structure where I pass NULL. To be honest I almost never use Blt (unless I need to stretch the image, which is rare) so I've never passed anything but NULL for the last param (lpDDBltFx).

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    142

    mickey

    you don't use blt? what do you use then?

  4. #4
    Unregistered
    Guest
    He probably uses BltFast. MSDN claims it is up to 10% faster than a standard Blt. BltFast pretty much has the same parameters as Blt , except you can't do some of the effects that you can with Blt. Therefore, if you don't need the effects than why not use BltFast, I like more FPS

  5. #5
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065

    Re: mickey

    Originally posted by mickey
    you don't use blt? what do you use then?
    I use BltFast almost exclusively. The only time I use Blt is if I want to manipulate the surface (stretch, etc.) which you can't do with BltFast. But it's rare that I ever need to do anything like that.

  6. #6
    Registered User
    Join Date
    Apr 2002
    Posts
    142
    blt and bltfast is just the same when it comes to hardware, bltfast will only be faster if the graphics is on the system memory,

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Direct Draw Question
    By cfrost in forum Game Programming
    Replies: 1
    Last Post: 09-24-2004, 05:01 PM
  2. Direct Draw: Rotating a bitmap
    By Diamonds in forum Game Programming
    Replies: 6
    Last Post: 09-08-2003, 02:36 PM
  3. Direct Draw 7 and Sprites
    By Zoalord in forum Game Programming
    Replies: 1
    Last Post: 08-13-2003, 01:10 PM
  4. Direct Draw weird stuff
    By Magos in forum C++ Programming
    Replies: 6
    Last Post: 04-24-2002, 05:39 AM
  5. Direct Draw problem
    By morbuz in forum Game Programming
    Replies: 5
    Last Post: 10-08-2001, 07:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21