Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(w3ddevice): resolve a multisampled back buffer for the screenshot
Olcay Seyganf4530d22dcd9
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4835b0afa..171dc9778 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -521,6 +521,11 @@ found and fixed — EA's own, not port damage.**- A screenshot no longer takes the game down when the window is bigger than the desktop. Asking fora 1600x1200 window on a 1080-tall monitor puts part of it off the screen, and the capture readthe whole client area out of a buffer that stops at the desktop's edge.+- A screenshot is a picture of the game. With anti-aliasing switched on, the capture could not read+ the frame the game had just drawn, so it photographed the desktop instead and said nothing about+ it. In a window with something in front of the game, that something is what you got: a browser, a+ chat window, whatever was on top. It reads the frame itself now, anti-aliasing or not, and what is+ in front of the window makes no difference to what comes out.- The arrow on a dropdown is square at every resolution. It was drawn into a slot of a fixed 21 pixels wide however tall the box around it was stretched, so the bigger the screen the more the arrow was squeezed.- The promotion screen closes when you press its key again, however fast you press it. The screen fades in, and the fade drives the window itself for several frames either way - so a second press during the fade read the screen as still shut and opened it again, and a press just after it was closed was undone by the fade's next frame.- The command bar stops changing under you while you are using it. With nothing selected the bar shows one of your builders so you can place a structure without picking a dozer first, and it showed whichever one happened to be idle - so a dozer finishing a building on the far side of the base took the bar over, dropping a half-typed build hotkey and taking the structure off your cursor. The builder you are working with keeps the bar.diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cppindex 5a06cac08..c84960c72 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp@@ -3426,19 +3426,39 @@ static IDirect3DSurface9 *captureBackBuffer(void)D3DSURFACE_DESC desc;bb->GetDesc(&desc);IDirect3DSurface9 *copy = NULL;- if ((desc.Format == D3DFMT_X8R8G8B8 || desc.Format == D3DFMT_A8R8G8B8) && desc.MultiSampleType == D3DMULTISAMPLE_NONE)- {- // The back buffer is a render target, so the copy has to come off it with- // GetRenderTargetData; UpdateSurface and StretchRect both refuse this direction.- if (SUCCEEDED(dev->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format,- D3DPOOL_SYSTEMMEM, ©, NULL)) && copy != NULL- && FAILED(dev->GetRenderTargetData(bb, copy)))+ if (desc.Format == D3DFMT_X8R8G8B8 || desc.Format == D3DFMT_A8R8G8B8)+ {+ // GetRenderTargetData refuses a multisampled source, and with -msaa or the options menu's+ // anti-aliasing set the back buffer is exactly that. StretchRect between two render+ // targets of the same size is D3D9's resolve, so the samples are averaged down into a+ // plain target first and the readback comes off that. Miss this and the caller falls+ // through to the front-buffer path, which photographs the desktop: whatever window happens+ // to sit over the game ends up in the screenshot, and nothing says so.+ IDirect3DSurface9 *resolved = NULL;+ IDirect3DSurface9 *source = bb;+ if (desc.MultiSampleType != D3DMULTISAMPLE_NONE+ && SUCCEEDED(dev->CreateRenderTarget(desc.Width, desc.Height, desc.Format,+ D3DMULTISAMPLE_NONE, 0, FALSE, &resolved, NULL))+ && SUCCEEDED(dev->StretchRect(bb, NULL, resolved, NULL, D3DTEXF_NONE)))+ {+ source = resolved;+ }++ if (SUCCEEDED(source->GetDesc(&desc)) && desc.MultiSampleType == D3DMULTISAMPLE_NONE+ && SUCCEEDED(dev->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format,+ D3DPOOL_SYSTEMMEM, ©, NULL)) && copy != NULL+ && FAILED(dev->GetRenderTargetData(source, copy))){copy->Release();copy = NULL;}++ if (resolved != NULL)+ resolved->Release();}bb->Release();+ if (copy == NULL)+ DEBUG_LOG(("takeScreenShot - the back buffer could not be read, falling back to a desktop capture\n"));return copy;}