Skip to content

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.

fix(ww3d2): keep the renderer a match started with across alt-tab

Olcay Seygan6b4d168c7772
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d4b3a0b6b..846c663ee 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -210,6 +210,7 @@ found and fixed — EA's own, not port damage.**
- The game draws its picture through Direct3D 11 now, and falls back to the old renderer on a machine that cannot make a Direct3D 11 device. Eight views over five maps come out within one step of one colour channel of the old picture, which is the smallest difference a screen can show.
- The Direct3D 11 picture comes with its finishing passes on, no switch needed. Explosions glow past their own edges, because the battlefield is kept brighter than white until the glow is worked out; jagged edges are smoothed; and a light sharpening brings the 2003 textures back up after the smoothing. All three run over the battlefield only, before the health bars and the command bar go on top, so the lettering is untouched. In a screen of thirty inferno cannons firing the frame averaged 11.89ms with them against 11.82ms without. The antialiasing setting on the display page is for the old renderer; `-dx11post off` on the command line gives you the plain picture, and `-dx11post fxaa` picks effects one by one. The old renderer's rolling-wave sea never went missing in a real match either: both of the game's settings files turn it off, so no map ever drew it.
+- Alt-tabbing out of a fullscreen match and back no longer leaves every building already on the map as a dark shadow with nothing standing in it. Fullscreen starts on the old picture, and coming back from the desktop switched the game over to Direct3D 11 halfway through the match. The new picture only knew about what was built after the switch, so older buildings drew as their shadow alone while a new one beside them looked fine. A match keeps the picture it started with now.
- 481 base-game textures at four times the resolution now beat Zero Hour's downscaled copies.
- A long thin texture loads at the size it was drawn at. Anything wider than eight to one used to be stretched onto a bigger, blurrier one, because that was the limit of a 2002 graphics card; the card is asked now, and modern ones have no such limit.
- Anything standing still keeps its shadow in the fog. A town you have already walked through used
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp
index 2ca108472..737ddc68b 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp
@@ -1364,8 +1364,11 @@ bool DX8Wrapper::Set_Render_Device(int dev, int width, int height, int bits, int
// The Direct3D 11 device is built beside the Direct3D 9 one rather than instead of it: 236
// places still call the D3D9 device directly, so taking it away would be a black screen. It
- // is on unless -d3d9 or -headless turned it off.
- if (Direct3D11_Is_Enabled() && !Direct3D11_Is_Active()) {
+ // is on unless -d3d9 or -headless turned it off. Only a new device gets one: a buffer or texture
+ // made before this point has no Direct3D 11 copy, so a device that was refused at startup and
+ // then created on a reset (an Alt-Tab out of fullscreen) drew every building already standing
+ // as nothing but its shadow.
+ if (!reset_device && Direct3D11_Is_Enabled() && !Direct3D11_Is_Active()) {
const bool created = Direct3D11_Create((HWND)_Hwnd,
_PresentParameters.BackBufferWidth, _PresentParameters.BackBufferHeight);
WWDEBUG_SAY(("-dx11: Direct3D 11 device %s\n", created ? "created" : "refused"));