Original Post
I've recently torn out some of the Win32 blitting functions I had used in my graphics engine and replaced them with the DirectDraw versions, and I was wondering about DirectDraw's capabilities of image rotation and alpha blending. These two things were the main reason I did this (plus the fact that BitBlt was too slow with big images), and I was rather excited about the prospect of being able to use alpha blending AND rotation using DirectDraw, instead of D3D. Yet, of course, I was disappointed... When I attempted to use angle rotation in "IDirectDraw::Blt()", it returned an error that there was no hardware support. Also, I tried using alpha blending in the same function, and again I was disappointed, again. Is there some way to make this work? Am I doing something wrong in my functions? Here's the code I am using:
//Variables being used:
LPDIRECTDRAWSURFACE lpDDS; //The currently focused on DD surface
HDC hdc; //The corresponding HDC with the surface
CSprite &sprite //Reference, not pointer
LPDIRECTDRAWSURFACE CSprite::ddsSprite;
bool CSprite::transparent;
UINT CSprite::tColor; //Transparent color
long srcX, srcY, srcW, srcH, dx, dy; //Source and destination variables
BYTE alpha; //Alpha value
//Code:
DDBLTFX fxCur;
DWORD fxFlags;
ZeroMemory(&fxCur,sizeof(fxCur));
fxCur.dwSize=sizeof(fxCur);
fxFlags=DDBLT_WAIT;
RECT rectSrc={srcX,srcY,srcX+srcW,srcY+srcH}, rectDest={dx,dy,dx+srcW,dy+srcH};
if (sprite.transparent) {
//Another question: How do you make tranpsarency using a certain color?
DDCOLORKEY fxColorKey={0xFF,0xFF}; //This sort-of works
fxCur.ddckSrcColorkey=fxColorKey;
fxFlags|=DDBLT_KEYSRCOVERRIDE;
}
if (alpha!=255) {
fxCur.dwAlphaSrcConst=alpha;
fxFlags|=DDBLT_ALPHASRCCONSTOVERRIDE;
}
//The rotation is a random test
fxCur.dwRotationAngle=4500;
fxFlags|=DDBLT_ROTATIONANGLE;
lpDDS->ReleaseDC(hdc);
HRESULT hresult=lpDDS->Blt(&rectDest,sprite.ddsSprite,&rectSrc,fxFlags,&fxCur);
lpDDS->GetDC(&hdc);