View Full Version : blitting problem
cozman
03-27-2002, 10:31 PM
Hey, I have found the final bug in this portion of my program and narrowed it down to a single line:
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 :)
MrWizard
04-01-2002, 12:56 AM
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.
cozman
04-01-2002, 01:25 AM
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!
Unregistered
04-01-2002, 03:28 AM
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 :)
MrWizard
04-01-2002, 03:29 AM
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"
cozman
04-01-2002, 10:01 PM
thanks, ill let you know how it comes out
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.