|
发表于 2004-7-1 13:25:00
|
显示全部楼层
Re:大家好,我想问问怎样重载Direct的BltFast()函数?
你可以从IDirectDrawSurface类中派生一个新类,然后加入一个BltFast函数,这样就可以实现重载,更简单的就是用下面这个函数来代替BltFast函数,这个函数是我随便写的,没测试是否正确。
HRESULT Blt( long x, long y, LPDIRECTDRAWSURFACE7 pdds, RECT* prc ,LPDIRECTDRAWSURFACE7 pddsBackBuffer)
{
RECT rc=*prc;
RECT ScreenRect;
GetClientRect(GetHWnd() ,&ScreenRect);
//开始栽剪
if(x<0){rc.left -=x;x=0;}
if(x+rc.right-rc.left >ScreenRect.right ){rc.right -=x+rc.right-rc.left -ScreenRect.right ;}
if(y<0){rc.top -=y;y=0;}
if(y+rc.bottom-rc.top >ScreenRect.bottom ){rc.bottom -=y+rc.bottom -rc.top -ScreenRect.bottom ;}
pddsBackBuffer->BltFast( x, y, pdds, &rc, DDBLTFAST_SRCCOLORKEY );
} |
|