mirror of
https://github.com/isledecomp/isle-portable.git
synced 2025-09-22 11:31:57 -04:00
Use DDBLT_COLORFILL to clear screen (#505)
This commit is contained in:
parent
0191be7461
commit
3868071fb8
@ -519,35 +519,25 @@ BOOL MxDirectDraw::DDCreateSurfaces()
|
||||
void MxDirectDraw::ClearBackBuffers()
|
||||
{
|
||||
HRESULT result;
|
||||
byte* line;
|
||||
DDSURFACEDESC ddsd;
|
||||
DDBLTFX ddbltfx;
|
||||
int count = m_bFlipSurfaces ? 2 : 1;
|
||||
int value = 0;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
memset(&ddsd, 0, sizeof(ddsd));
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
memset(&ddbltfx, 0, sizeof(ddbltfx));
|
||||
ddbltfx.dwSize = sizeof(ddbltfx);
|
||||
ddbltfx.dwFillColor = 0;
|
||||
|
||||
result = m_pBackBuffer->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_WRITEONLY, NULL);
|
||||
result = m_pBackBuffer->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
|
||||
if (result == DDERR_SURFACELOST) {
|
||||
m_pBackBuffer->Restore();
|
||||
result = m_pBackBuffer->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_WRITEONLY, NULL);
|
||||
result = m_pBackBuffer->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
|
||||
}
|
||||
|
||||
if (result != DD_OK) {
|
||||
// lock failed
|
||||
// blt failed
|
||||
return;
|
||||
}
|
||||
|
||||
// clear backBuffer
|
||||
line = (byte*) ddsd.lpSurface;
|
||||
for (int j = ddsd.dwHeight; j--;) {
|
||||
memset(line, value, ddsd.dwWidth);
|
||||
line += ddsd.lPitch;
|
||||
}
|
||||
|
||||
m_pBackBuffer->Unlock(ddsd.lpSurface);
|
||||
|
||||
if (m_bFlipSurfaces) {
|
||||
m_pFrontBuffer->Flip(NULL, DDFLIP_WAIT);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user