blitting problem

This is a discussion on blitting problem within the Game Programming forums, part of the General Programming Boards category; Hey, I have found the final bug in this portion of my program and narrowed it down to a single ...

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

    blitting problem

    Hey, I have found the final bug in this portion of my program and narrowed it down to a single line:
    Code:
    DoError((char*)DXGetErrorDescription8(dest->Blt(&destRect, Image[frame], &srcRect, 
          DDBLT_KEYSRC|DDBLT_WAIT, NULL)));
    	//error is that there are invalid parameters, commenting out DDBLT_KEYSRC fixes this
    I have attached the entire file below (it isn't too long just 140 lines, and most can be ignored b/c the error must be in certain places) and I would greatly appreciate it if anybody can find why I am getting the invalid parameter error from this code. Thanks so much
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    RECT destRect;

    //horizontal extent
    destRect.left = x;
    destRect.right = destRect.left + Width;

    //vertical extent
    destRect.top = y;
    destRect.bottom = y+Height;

    //blit it
    DoError((char*)DXGetErrorDescription8(dest->Blt( &destRect, Image[frame], &srcRect, DDBLT_KEYSRC | DDBLT_WAIT, NULL)));
    //error is that there are invalid parameters, commenting out DDBLT_KEYSRC fixes this

    Excuse the mess , I'm new to the CODE tag, when trying to post Code... anyways, I dont see where you defined RECT srcRect . That would certainly be an invalid parameter. I see where you defined destRect, but not the source. Maybe I am blind.

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

    it's acutally part of a class :) sorry to leave that one out

    I am sure that the invalid param is DDBLT_KEYSRC... i have tested w/ and w/o it and i only get the error with it. that rect is actually a private class member if you noticed in the attached file. Thanks for trying to help.. if you have any DD7 code w/ transparency please share



    MY 200th Post!!!!!!!!!!!!!!
    Wooooo!
    2-0-0!

  4. #4
    Unregistered
    Guest
    Okay, here are some snippets from my game. Um, they are intentionally copy and pasted missing sections, but should show you how I transparently blit my sprites to my back buffer and then flip.

    DDCOLORKEY magnus = {0x00FF00FF, 0x00FF00FF};
    DDSURFACEDESC2 ddsd;

    ddsd.dwSize = sizeof(ddsd);
    ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CKSRCBLT;
    ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
    ddsd.ddsCaps.dwCaps2 = ddsd.ddsCaps.dwCaps3 = ddsd.ddsCaps.dwCaps4 = 0;
    ddsd.dwWidth = CX_SPRITE;
    ddsd.dwHeight = ( siCount * CY_SPRITE );
    ddsd.ddckCKSrcBlt = magnus;

    if(FAILED( hr = pDD7->CreateSurface( &ddsd, &pDDOS, NULL ) ) )
    {
    pDDSurface->Release();
    pDD7->Release();
    return 0;
    }


    that's where i setup my off-screen surface for my sprites, with the source key blitting..... Then when i blit, here is the line of code...

    // Draw our main character sprite to the screen
    HRESULT hResult = pDDBack->Blt( &rectDst, pDDOS, &rectSrc, DDBLT_WAIT | DDBLT_KEYSRC, NULL );


    Hope this helps

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Oops, that was my post above, I don't know why it shows it as unregistered??? So if you have any questions about that code, e-mail me or catch my on AIM "purged by request"
    Last edited by Thantos; 09-27-2005 at 12:08 AM. Reason: Removing AIM address, by request

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

    thanks for that

    thanks, ill let you know how it comes out

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 09:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 03:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 07:54 PM
  5. Problem with blitting dibSections
    By samGwilliam in forum Windows Programming
    Replies: 4
    Last Post: 01-22-2007, 06:15 PM

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