-
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
-
What error code does it return?
-
-
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.
-
I'll try to get that error code later today.
-
OK, finaly got off my ass, and I got the HRESULT. It is: 40006d09
does this help?
-
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.
-
Alright, thanks. That really is useless! :confused:
-
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
-
/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.
-
LOL. Can't believe we missed that!!! :D
Yeah so DirectX is saying you can't blit into an area that has an infinite/undefined bottom dimension.
-
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