diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp index 3f3b1e40df..97770f6ab1 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp @@ -491,6 +491,11 @@ void W3DDisplay::setGamma(Real gamma, Real bright, Real contrast, Bool calibrate //============================================================================= Bool W3DDisplay::setDisplayMode( UnsignedInt xres, UnsignedInt yres, UnsignedInt bitdepth, Bool windowed ) { + const UnsignedInt oldWidth = getWidth(); + const UnsignedInt oldHeight = getHeight(); + const UnsignedInt oldBitDepth = getBitDepth(); + const Bool oldWindowed = getWindowed(); + if (WW3D_ERROR_OK == WW3D::Set_Device_Resolution(xres,yres,bitdepth,windowed,true)) { Render2DClass::Set_Screen_Resolution(RectClass(0, 0, xres, yres)); @@ -499,9 +504,9 @@ Bool W3DDisplay::setDisplayMode( UnsignedInt xres, UnsignedInt yres, UnsignedInt } //set back to the original mode. - WW3D::Set_Device_Resolution(getWidth(),getHeight(),getBitDepth(),getWindowed(), true); - Render2DClass::Set_Screen_Resolution(RectClass(0, 0, getWidth(),getHeight())); - Display::setDisplayMode(getWidth(),getHeight(),getBitDepth(), getWindowed()); + WW3D::Set_Device_Resolution(oldWidth, oldHeight, oldBitDepth, oldWindowed, true); + Render2DClass::Set_Screen_Resolution(RectClass(0, 0, oldWidth, oldHeight)); + Display::setDisplayMode(oldWidth, oldHeight, oldBitDepth, oldWindowed); return FALSE; //did not change to a new mode. } diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp index 4dc573beee..8d966ebdbe 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp @@ -349,11 +349,6 @@ void DX8Wrapper::Shutdown() } } - if (D3DInterface) { - UINT newRefCount=D3DInterface->Release(); - D3DInterface=nullptr; - } - if (D3D8Lib) { FreeLibrary(D3D8Lib); D3D8Lib = nullptr; @@ -830,7 +825,7 @@ void DX8Wrapper::Resize_And_Position_Window() // Resize the window to fit this resolution if (!IsWindowed) { - ::SetWindowPos(_Hwnd, HWND_TOPMOST, 0, 0, width, height, SWP_NOSIZE | SWP_NOMOVE); + ::SetWindowPos(_Hwnd, HWND_TOPMOST, 0, 0, width, height, 0); DEBUG_LOG(("Window resized to w:%d h:%d", width, height)); } @@ -883,9 +878,6 @@ bool DX8Wrapper::Set_Render_Device(int dev, int width, int height, int bits, int if (width != -1) ResolutionWidth = width; if (height != -1) ResolutionHeight = height; - // Initialize Render2DClass Screen Resolution - Render2DClass::Set_Screen_Resolution( RectClass( 0, 0, ResolutionWidth, ResolutionHeight ) ); - if (bits != -1) BitDepth = bits; if (windowed != -1) IsWindowed = (windowed != 0); DX8Wrapper_IsWindowed = IsWindowed; @@ -1053,6 +1045,11 @@ bool DX8Wrapper::Set_Render_Device(int dev, int width, int height, int bits, int WWDEBUG_SAY(("Reset/Create_Device done, reset_device=%d, restore_assets=%d", reset_device, restore_assets)); + if (ret) + { + Render2DClass::Set_Screen_Resolution( RectClass( 0, 0, ResolutionWidth, ResolutionHeight ) ); + } + return ret; } diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp index e34e442864..6a17841b0f 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp @@ -541,6 +541,11 @@ void W3DDisplay::setGamma(Real gamma, Real bright, Real contrast, Bool calibrate //============================================================================= Bool W3DDisplay::setDisplayMode( UnsignedInt xres, UnsignedInt yres, UnsignedInt bitdepth, Bool windowed ) { + const UnsignedInt oldWidth = getWidth(); + const UnsignedInt oldHeight = getHeight(); + const UnsignedInt oldBitDepth = getBitDepth(); + const Bool oldWindowed = getWindowed(); + if (WW3D_ERROR_OK == WW3D::Set_Device_Resolution(xres,yres,bitdepth,windowed,true)) { Render2DClass::Set_Screen_Resolution(RectClass(0, 0, xres, yres)); @@ -549,9 +554,9 @@ Bool W3DDisplay::setDisplayMode( UnsignedInt xres, UnsignedInt yres, UnsignedInt } //set back to the original mode. - WW3D::Set_Device_Resolution(getWidth(),getHeight(),getBitDepth(),getWindowed(), true); - Render2DClass::Set_Screen_Resolution(RectClass(0, 0, getWidth(),getHeight())); - Display::setDisplayMode(getWidth(),getHeight(),getBitDepth(), getWindowed()); + WW3D::Set_Device_Resolution(oldWidth, oldHeight, oldBitDepth, oldWindowed, true); + Render2DClass::Set_Screen_Resolution(RectClass(0, 0, oldWidth, oldHeight)); + Display::setDisplayMode(oldWidth, oldHeight, oldBitDepth, oldWindowed); return FALSE; //did not change to a new mode. } diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp index 956540ddae..0d3f6bc7a6 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp @@ -353,11 +353,6 @@ void DX8Wrapper::Shutdown() } } - if (D3DInterface) { - UINT newRefCount=D3DInterface->Release(); - D3DInterface=nullptr; - } - if (D3D8Lib) { FreeLibrary(D3D8Lib); D3D8Lib = nullptr; @@ -896,7 +891,7 @@ void DX8Wrapper::Resize_And_Position_Window() // Resize the window to fit this resolution if (!IsWindowed) { - ::SetWindowPos(_Hwnd, HWND_TOPMOST, 0, 0, width, height, SWP_NOSIZE | SWP_NOMOVE); + ::SetWindowPos(_Hwnd, HWND_TOPMOST, 0, 0, width, height, 0); DEBUG_LOG(("Window resized to w:%d h:%d", width, height)); } @@ -949,9 +944,6 @@ bool DX8Wrapper::Set_Render_Device(int dev, int width, int height, int bits, int if (width != -1) ResolutionWidth = width; if (height != -1) ResolutionHeight = height; - // Initialize Render2DClass Screen Resolution - Render2DClass::Set_Screen_Resolution( RectClass( 0, 0, ResolutionWidth, ResolutionHeight ) ); - if (bits != -1) BitDepth = bits; if (windowed != -1) IsWindowed = (windowed != 0); DX8Wrapper_IsWindowed = IsWindowed; @@ -1120,6 +1112,11 @@ bool DX8Wrapper::Set_Render_Device(int dev, int width, int height, int bits, int WWDEBUG_SAY(("Reset/Create_Device done, reset_device=%d, restore_assets=%d", reset_device, restore_assets)); + if (ret) + { + Render2DClass::Set_Screen_Resolution( RectClass( 0, 0, ResolutionWidth, ResolutionHeight ) ); + } + return ret; }