Blting question

This is a discussion on Blting question within the Game Programming forums, part of the General Programming Boards category; Right, I can blt a BMP to the backbuffer, and then flip. This works just fine, but when I add ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    180

    Blting question

    Right, I can blt a BMP to the backbuffer, and then flip. This works just fine, but when I add another surface, and try to blt one after another, it doesn't work. The blt fails. Now, I don't have colorkey. Is this going to be an issue? Here is my code:

    Code:
    #include "Unit1.h"
    #include <ddraw.h>
    #include "Mercury.h"
    
    extern LPDIRECTDRAW7 lpdd;  //version 7.0 main
    extern MercuryEngine GameEngine; //Main GameEngine
    
    class BOB
    {
    public:
     int x,y; //x-y coords
     LPDIRECTDRAWSURFACE7 DDBOB; //DX BACK surface
     RECT src_rect;
     RECT dest_rect;
     BOB();
    };
    
    BOB::BOB()
    {
    //int bob!
    
               this->src_rect.left = 0;
               this->src_rect.top = 0;
               this->src_rect.right = 63;
               this->src_rect.left = 63;
    
               this->dest_rect.left = 100;
               this->dest_rect.top = 100;
               this->dest_rect.right = 100+63;
               this->dest_rect.left = 100+64;
    
               this->x = 100;
               this->y = 100;
    
    }
    
    ...
    
    BOB bob;
    
    ...
    
    if(FAILED(DDback->Blt(&dest_rect,DDback_sprite,&src_rect,DDBLT_WAIT, NULL)))
    {
     Application->MessageBoxA("Error","Boom",MB_OK);
     Application->Terminate();
    }
    
    
    if(FAILED(DDback->Blt(&bob.dest_rect,bob.DDBOB,&bob.src_rect ,DDBLT_WAIT,NULL)))
    {
      Application->MessageBoxA("BOB don't like you!","Boom",MB_OK);
     Application->Terminate();
    }

    Its the second BLT that fails.


    Also, if I put the LoadBitmap for BOB into the constructor of BOB, it get what seems to be an adress error.

    Any ideas?

    Cheers

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    What error code does it return?
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    How would I tell?

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    Every DirectX function, or nearly every function, returns an HRESULT. Based on that you can then extract the error using the DirectX provided function (look in the SDK) or by looking the result up in the DirectX SDK help file.

  5. #5
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    I'll try to get that error code later today.

  6. #6
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    OK, finaly got off my ass, and I got the HRESULT. It is: 40006d09

    does this help?

  7. #7
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    I run it through the DirectX 9 Error lookup tool ( that comes with the SDK ) and get the following useless information about that code:

    HRESULT: 0x40006d09 (1073769737)
    Name: Unknown
    Description: n/a
    Severity code: Success
    Facility Code: FACILITY_NULL (0)
    Error Code: 0x6d09 (27913)

    What version of DirectX are you using?

    edit: I see , DirectX 7. Let me look around a little bit.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  8. #8
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    Alright, thanks. That really is useless!

  9. #9
    Registered User
    Join Date
    Jun 2004
    Posts
    201
    Code:
    this->src_rect.left = 0;
    this->src_rect.top = 0;
    this->src_rect.right = 63;
    this->src_rect.left = 63;
    
    this->dest_rect.left = 100;
    this->dest_rect.top = 100;
    this->dest_rect.right = 100+63;
    this->dest_rect.left = 100+64;
    You're writing left twice and leave bottom uninitialised

  10. #10
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    /bow

    Good man! Thanks a ton! I wasn't even looking there.....You sir, are my hero!

    I also figured out WTH that error code means. It meas "There is so much wrong with your programming....", Looks like it was a combo between my Clipper set up(which is also fux0red) as well as the rect issue.

  11. #11
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    LOL. Can't believe we missed that!!!

    Yeah so DirectX is saying you can't blit into an area that has an infinite/undefined bottom dimension.

  12. #12
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    makes sense. I'm surprised we all missed that actually! Its so obvious when I look at the code now...well, I guess I learnt me lesson!

    Thanks all

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

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