|
//////////////////////////////////
//游戏初始化
//////////////////////////////////
int GameInit(void)
{
//DirectDraw处始化
MyDirectDrawInit();
//剪切序列
RECT rect_list[3] = {{10,10,50,50}, {100,100,200,200},
{300,300, 400, 400}};
//建立剪切区
if (FAILED(lpDDclip = CreatDDClipper(lpDDback,3,rect_list)))
{MessageBox(NULL,TEXT("primary surface Blt error!"), TEXT("primary surface Blt error!Wrong!"),MB_OK);
return(0);
}
return 0;
}
/////////////////////////////////////////////
//DirectDraw剪切板
/////////////////////////////////////////////
LPDIRECTDRAWCLIPPER CreatDDClipper(LPDIRECTDRAWSURFACE7 lpDDraw,
int Clipnumber,
LPRECT clipsqe)
{
int index;
LPDIRECTDRAWCLIPPER lpDDtempclip; //Directdraw剪切板
LPRGNDATA clipregion; //剪切区域序列
//创建剪切板
if (FAILED(lpDDraw7->CreateClipper(0,&lpDDtempclip,NULL)))
{
MessageBox(NULL,TEXT("DirectDraw Create clipper error!"),
TEXT("Wrong!"),MB_OK);
return(NULL);
}
//定义剪切区
clipregion = (LPRGNDATA)malloc(sizeof(RGNDATAHEADER)+Clipnumber*sizeof(RECT));
memcpy(clipregion->Buffer, clipsqe, sizeof(RECT)*Clipnumber);
clipregion->rdh.dwSize = sizeof(RGNDATAHEADER);
clipregion->rdh.iType = RDH_RECTANGLES;
clipregion->rdh.nCount = Clipnumber;
clipregion->rdh.nRgnSize = Clipnumber*sizeof(RECT);
clipregion->rdh.rcBound.left = 80000;
clipregion->rdh.rcBound.top = 80000;
clipregion->rdh.rcBound.right = -80000;
clipregion->rdh.rcBound.bottom = -80000;
for (index=0; index<Clipnumber; index++)
{
if (clipsqe[index].left < clipregion->rdh.rcBound.left)
clipregion->rdh.rcBound.left = clipsqe[index].left;
if (clipsqe[index].right > clipregion->rdh.rcBound.right)
clipregion->rdh.rcBound.right = clipsqe[index].right;
if (clipsqe[index].top < clipregion->rdh.rcBound.top)
clipregion->rdh.rcBound.top = clipsqe[index].top;
if (clipsqe[index].bottom > clipregion->rdh.rcBound.bottom)
clipregion->rdh.rcBound.bottom = clipsqe[index].bottom;
}
if (FAILED(lpDDtempclip->SetClipList(clipregion, 0)))
{
free(clipregion);
return(NULL);
}
if (FAILED(lpDDraw->SetClipper(lpDDtempclip)))
{
free(clipregion);
return(NULL);
}
free(clipregion);
return(lpDDtempclip);
}
应该是CreatDDClipper这个函数的问题,可我解决不了,大侠们多指点
[em7] [em7] [em7] |
|