Use DDBLT_COLORFILL to clear screen (#505)

This commit is contained in:
Anders Jenbo 2025-07-03 20:12:55 +02:00 committed by GitHub
parent 0191be7461
commit 3868071fb8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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);
}