From c382779bbaa3c32936987722a15d59d4663a2ce1 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sun, 23 Dec 2018 09:50:57 -0800 Subject: Fixed issue with binding default framebuffer in OpenGL --- Graphics/GraphicsEngine/include/DeviceContextBase.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'Graphics/GraphicsEngine') diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.h b/Graphics/GraphicsEngine/include/DeviceContextBase.h index 51420d83..23bd88c9 100644 --- a/Graphics/GraphicsEngine/include/DeviceContextBase.h +++ b/Graphics/GraphicsEngine/include/DeviceContextBase.h @@ -512,10 +512,14 @@ inline bool DeviceContextBase :: { VERIFY(m_pSwapChain, "Swap chain is not initialized in the device context"); - NumRenderTargets = 1; - pDefaultRTV = m_pSwapChain->GetCurrentBackBufferRTV(); - ppRenderTargets = &pDefaultRTV; + pDefaultRTV = m_pSwapChain->GetCurrentBackBufferRTV(); pDepthStencil = m_pSwapChain->GetDepthBufferDSV(); + // In OpenGL, default RTV and DSV are null + if (pDefaultRTV != nullptr) + { + NumRenderTargets = 1; + ppRenderTargets = &pDefaultRTV; + } const auto &SwapChainDesc = m_pSwapChain->GetDesc(); m_FramebufferWidth = SwapChainDesc.Width; @@ -523,7 +527,7 @@ inline bool DeviceContextBase :: m_FramebufferSlices = 1; } - if ( NumRenderTargets != m_NumBoundRenderTargets ) + if (NumRenderTargets != m_NumBoundRenderTargets) { bBindRenderTargets = true; for(Uint32 rt = NumRenderTargets; rt < m_NumBoundRenderTargets; ++rt ) @@ -532,7 +536,7 @@ inline bool DeviceContextBase :: m_NumBoundRenderTargets = NumRenderTargets; } - for( Uint32 rt = 0; rt < NumRenderTargets; ++rt ) + for (Uint32 rt = 0; rt < NumRenderTargets; ++rt) { auto* pRTView = ppRenderTargets[rt]; if ( pRTView ) @@ -568,14 +572,14 @@ inline bool DeviceContextBase :: // Here both views are certainly live objects, since we store // strong references to all bound render targets. So we // can safely compare pointers. - if ( m_pBoundRenderTargets[rt] != pRTView ) + if (m_pBoundRenderTargets[rt] != pRTView) { m_pBoundRenderTargets[rt] = ValidatedCast(pRTView); bBindRenderTargets = true; } } - if ( pDepthStencil ) + if (pDepthStencil != nullptr) { const auto &DSVDesc = pDepthStencil->GetDesc(); #ifdef DEVELOPMENT -- cgit v1.2.3