今天写了如下代码:
m_pDDSBackUp->GetDC(&hdcBackUp);
imBackGround.Draw(hdcBackUp,rBackGround);
imCorps.Draw(hdcBackUp,rDesCorps);
m_pDDSBackground->Blt(NULL,m_pDDSBackUp , NULL, DDBLT_WAITNOTBUSY, NULL);
m_pDDSBackUp->ReleaseDC(hdcBackUp);
pDDSurface->Blt(NULL, m_pDDSBackground, NULL, DDBLT_WAITNOTBUSY, NULL);
其中pDDSurface是backsurface, m_pDDSBackUp是备份surface,用来存放上一帧动画, m_pDDSBackground放的是背景surface
结果,一片黑~~~
分析啊分析,发现了,在对其DC操作时进行Blt是无效的,代码改为:
m_pDDSBackUp->GetDC(&hdcBackUp);
imBackGround.Draw(hdcBackUp,rBackGround);
imCorps.Draw(hdcBackUp,rDesCorps);
m_pDDSBackUp->ReleaseDC(hdcBackUp);//改变这里,先关闭再blt
m_pDDSBackground->Blt(NULL,m_pDDSBackUp , NULL, DDBLT_WAITNOTBUSY, NULL);
pDDSurface->Blt(NULL, m_pDDSBackground, NULL, DDBLT_WAITNOTBUSY, NULL);