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): give the desktop gamma back under -d3d9, round the pointer up

Olcay Seygan7d4cde871264
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/GameClient/Win32Mouse.cpp b/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/GameClient/Win32Mouse.cpp
index 99aa15a97..96e9fd0a7 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/GameClient/Win32Mouse.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/GameClient/Win32Mouse.cpp
@@ -109,10 +109,12 @@ static void gameToWindow( Int &x, Int &y )
return;
const Int width = TheDisplay->getWidth();
const Int height = TheDisplay->getHeight();
+ // rounded up, so windowToGame brings the point back to where it started while the window is the
+ // larger of the two; the freecam re-centres the pointer every frame and reads the difference
if( width > 0 && client.right != width )
- x = (Int)( ( (Int64)x * client.right ) / width );
+ x = (Int)( ( (Int64)x * client.right + width - 1 ) / width );
if( height > 0 && client.bottom != height )
- y = (Int)( ( (Int64)y * client.bottom ) / height );
+ y = (Int)( ( (Int64)y * client.bottom + height - 1 ) / height );
}
//-------------------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp
index f0b98d9ce..c41a09706 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp
@@ -4589,10 +4589,10 @@ void DX8Wrapper::Set_Gamma(float gamma,float bright,float contrast,bool calibrat
if (Get_Current_Caps()->Support_Gamma() && !_PresentParameters.Windowed) {
DX8Wrapper::_Get_D3D_Device()->SetGammaRamp(PRIMARY_SWAP_CHAIN,flag,&ramp);
- } else if (Direct3D11_Present_Is_Enabled()) {
- // A windowed Direct3D 9 device ignores its gamma ramp, so the fullscreen display under the
- // Direct3D 11 picture sets the desktop's, keeps the desktop's own to give back on the way out,
- // and puts the game's on again when the game comes back.
+ } else if (!IsWindowed || Direct3D11_Present_Is_Enabled()) {
+ // A windowed Direct3D 9 device ignores its gamma ramp, and a fullscreen game's device is a
+ // windowed one under either renderer, so the fullscreen display sets the desktop's, keeps the
+ // desktop's own to give back on the way out, and puts the game's on again when it comes back.
save_desktop_gamma();
GameGammaRamp = ramp;
GameGammaSet = true;