From 5f28d47af17eec8632ea0437066631f2353cecba Mon Sep 17 00:00:00 2001 From: assiduous Date: Mon, 27 Apr 2020 13:29:49 -0700 Subject: Improved swap chain resize handling on Android --- .../src/DeviceContextGLImpl.cpp | 1 + .../GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp | 30 ++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp index c64c41cd..f6308229 100644 --- a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp @@ -400,6 +400,7 @@ void DeviceContextGLImpl::ResetRenderTargets() { TDeviceContextBase::ResetRenderTargets(); m_IsDefaultFBOBound = false; + m_ContextState.InvalidateFBO(); } diff --git a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp index 3b6ebe8e..420449fb 100644 --- a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp @@ -121,8 +121,34 @@ void SwapChainGLImpl::Resize(Uint32 NewWidth, Uint32 NewHeight, SURFACE_TRANSFOR auto* pDeviceGL = m_pRenderDevice.RawPtr(); auto& GLContext = pDeviceGL->m_GLContext; GLContext.UpdateScreenSize(); - NewWidth = GLContext.GetScreenWidth(); - NewHeight = GLContext.GetScreenHeight(); + const auto ScreenWidth = GLContext.GetScreenWidth(); + const auto ScreenHeight = GLContext.GetScreenHeight(); + + if (NewWidth == 0) + { + NewWidth = ScreenWidth; + } + else + { + if (NewWidth != ScreenWidth) + { + LOG_WARNING_MESSAGE("Requested new swap chain width (", NewWidth, ") does not match GLES surface width (", ScreenWidth, + "). This may be the result of calling Resize before the rotation has taken the effect."); + } + } + + if (NewHeight == 0) + { + NewHeight = ScreenHeight; + } + else + { + if (NewHeight != ScreenHeight) + { + LOG_WARNING_MESSAGE("Requested new swap chain height (", NewHeight, ") does not match GLES surface height (", ScreenHeight, + "). This may be the result of calling Resize before the rotation has taken the effect."); + } + } #endif TSwapChainGLBase::Resize(NewWidth, NewHeight, NewPreTransform, 0); -- cgit v1.2.3