diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp index 32c1eee474..be615acde7 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp @@ -964,12 +964,15 @@ void WaterRenderObjClass::ReAcquireResources(void) if (m_whiteTexture && !m_whiteTexture->Is_Initialized()) { m_whiteTexture->Init(); SurfaceClass *surface=m_whiteTexture->Get_Surface_Level(); - int pitch; - void *pBits = surface->Lock(&pitch); - const unsigned int bytesPerPixel = surface->Get_Bytes_Per_Pixel(); - surface->Draw_Pixel(0, 0, 0xffffffff, bytesPerPixel, pBits, pitch); - surface->Unlock(); - REF_PTR_RELEASE(surface); + if (surface) + { + int pitch; + void *pBits = surface->Lock(&pitch); + const unsigned int bytesPerPixel = surface->Get_Bytes_Per_Pixel(); + surface->Draw_Pixel(0, 0, 0xffffffff, bytesPerPixel, pBits, pitch); + surface->Unlock(); + REF_PTR_RELEASE(surface); + } } } @@ -1114,12 +1117,15 @@ Int WaterRenderObjClass::init(Real waterLevel, Real dx, Real dy, SceneClass *par //For some reason setting a null texture does not result in 0xffffffff for pixel shaders so using explicit "white" texture. m_whiteTexture=MSGNEW("TextureClass") TextureClass(1,1,WW3D_FORMAT_A4R4G4B4,MIP_LEVELS_1); SurfaceClass *surface=m_whiteTexture->Get_Surface_Level(); - int pitch; - void *pBits = surface->Lock(&pitch); - const unsigned int bytesPerPixel = surface->Get_Bytes_Per_Pixel(); - surface->Draw_Pixel(0, 0, 0xffffffff, bytesPerPixel, pBits, pitch); - surface->Unlock(); - REF_PTR_RELEASE(surface); + if (surface) + { + int pitch; + void *pBits = surface->Lock(&pitch); + const unsigned int bytesPerPixel = surface->Get_Bytes_Per_Pixel(); + surface->Draw_Pixel(0, 0, 0xffffffff, bytesPerPixel, pBits, pitch); + surface->Unlock(); + REF_PTR_RELEASE(surface); + } m_waterNoiseTexture=WW3DAssetManager::Get_Instance()->Get_Texture("Noise0000.tga"); m_riverAlphaEdge=WW3DAssetManager::Get_Instance()->Get_Texture("TWAlphaEdge.tga");