diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp index ccd6c9df7f9..41994fd362d 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp @@ -2371,7 +2371,14 @@ IDirect3DSurface8 * DX8Wrapper::_Create_DX8_Surface(unsigned int width, unsigned // Paletted surfaces not supported! WWASSERT(format!=D3DFMT_P8); - DX8CALL(CreateImageSurface(width, height, WW3DFormat_To_D3DFormat(format), &surface)); + HRESULT hr = DX8Wrapper::_Get_D3D_Device8()->CreateImageSurface(width, height, WW3DFormat_To_D3DFormat(format), &surface); + number_of_DX8_calls++; + + if (FAILED(hr)) { + // Log the error and return NULL to indicate failure + Non_Fatal_Log_DX8_ErrorCode(hr, __FILE__, __LINE__); + return NULL; + } return surface; } diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp index 16fe4e80eb0..32a9e2659d4 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp @@ -2943,7 +2943,14 @@ IDirect3DSurface8 * DX8Wrapper::_Create_DX8_Surface(unsigned int width, unsigned // Paletted surfaces not supported! WWASSERT(format!=D3DFMT_P8); - DX8CALL(CreateImageSurface(width, height, WW3DFormat_To_D3DFormat(format), &surface)); + HRESULT hr = DX8Wrapper::_Get_D3D_Device8()->CreateImageSurface(width, height, WW3DFormat_To_D3DFormat(format), &surface); + number_of_DX8_calls++; + + if (FAILED(hr)) { + // Log the error and return NULL to indicate failure + Non_Fatal_Log_DX8_ErrorCode(hr, __FILE__, __LINE__); + return NULL; + } return surface; }