Hey guys, I have a problem with my DirectDraw code. I'm trying to make a function that gets a snapshot of the screen, which can be later used to redraw the screen. I'm having troubles though, not sure exactly what. My function code is below (slightly modified, but not significantly).
I have tested the return values, and it was never NULL. It's just that whenever I try blitting the returned surface, it doesn't blit the original screen. Can anybody see any errors in the code that I missed?
//sfcFront and sfcBack are the front and back buffers of the screen.
IDirectDrawSurface7* GFX::getSnapshot(bool frontBuffer)
DDSURFACEDESC2 ddsd; //originally was class variable
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = scrnRect.right;
ddsd.dwHeight = scrnRect.bottom;
//ddBltFx is a class variable of GFX.
ddBltFx.dwSize = sizeof(ddBltFx);
//lpdd is the DirectDraw interface/object thinger
if(FAILED(lpdd->CreateSurface(&ddsd, &surface, NULL)))
if(FAILED(surface->Blt(NULL, sfcFront, NULL, DDBLT_WAIT, &ddBltFx)))
if(FAILED(surface->Blt(NULL, sfcBack, NULL, DDBLT_WAIT, &ddBltFx)))