diff --git a/source/graphics/LOSTexture.cpp b/source/graphics/LOSTexture.cpp index 8042dd3e11..c1de811fc9 100644 --- a/source/graphics/LOSTexture.cpp +++ b/source/graphics/LOSTexture.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -155,9 +155,6 @@ void CLOSTexture::InterpolateLOS() m_Dirty = false; } - GLint originalFBO; - glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &originalFBO); - pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_smoothFbo); pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, whichTex ? m_TextureSmooth2 : m_TextureSmooth1, 0); @@ -214,7 +211,7 @@ void CLOSTexture::InterpolateLOS() pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, 0, 0); - pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, originalFBO); + pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); whichTex = !whichTex; } diff --git a/source/renderer/PostprocManager.cpp b/source/renderer/PostprocManager.cpp index f4521fe891..098dde3dd3 100644 --- a/source/renderer/PostprocManager.cpp +++ b/source/renderer/PostprocManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -332,9 +332,6 @@ void CPostprocManager::ApplyBlur() { glDisable(GL_BLEND); - GLint originalFBO; - glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &originalFBO); - int width = m_Width, height = m_Height; #define SCALE_AND_BLUR(tex1, tex2, temptex) \ @@ -349,8 +346,6 @@ void CPostprocManager::ApplyBlur() SCALE_AND_BLUR(m_BlurTex4a, m_BlurTex8a, m_BlurTex8b); #undef SCALE_AND_BLUR - - pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, originalFBO); } @@ -496,6 +491,7 @@ void CPostprocManager::ApplyPostproc() // (This may need to change depending on future usage, however that will have a fps hit) ApplyBlur(); + pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo); for (int pass = 0; pass < m_PostProcTech->GetNumPasses(); ++pass) ApplyEffect(m_PostProcTech, pass); diff --git a/source/renderer/Renderer.cpp b/source/renderer/Renderer.cpp index 767c4f854b..b5ca16d4d1 100644 --- a/source/renderer/Renderer.cpp +++ b/source/renderer/Renderer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -1020,10 +1020,6 @@ void CRenderer::RenderReflections(const CShaderDefines& context, const CBounding { PROFILE3_GPU("water reflections"); - // Save the post-processing framebuffer. - GLint fbo; - glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &fbo); - WaterManager& wm = m->waterManager; // Remember old camera @@ -1087,10 +1083,7 @@ void CRenderer::RenderReflections(const CShaderDefines& context, const CBounding m_ViewCamera = normalCamera; m->SetOpenGLCamera(m_ViewCamera); - // rebind post-processing frambuffer. - pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo); - - return; + pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); } @@ -1100,10 +1093,6 @@ void CRenderer::RenderRefractions(const CShaderDefines& context, const CBounding { PROFILE3_GPU("water refractions"); - // Save the post-processing framebuffer. - GLint fbo; - glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &fbo); - WaterManager& wm = m->waterManager; // Remember old camera @@ -1151,10 +1140,7 @@ void CRenderer::RenderRefractions(const CShaderDefines& context, const CBounding m_ViewCamera = normalCamera; m->SetOpenGLCamera(m_ViewCamera); - // rebind post-processing frambuffer. - pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo); - - return; + pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); } void CRenderer::RenderSilhouettes(const CShaderDefines& context) @@ -1301,12 +1287,6 @@ void CRenderer::RenderSubmissions(const CBoundingBoxAligned& waterScissor) GetScene().GetLOSTexture().InterpolateLOS(); - if (g_RenderingOptions.GetPostProc()) - { - m->postprocManager.Initialize(); - m->postprocManager.CaptureRenderOutput(); - } - CShaderDefines context = m->globalContext; int cullGroup = CULL_DEFAULT; @@ -1338,21 +1318,6 @@ void CRenderer::RenderSubmissions(const CBoundingBoxAligned& waterScissor) RenderShadowMap(context); } - { - PROFILE3_GPU("clear buffers"); - glClearColor(m_ClearColor[0], m_ClearColor[1], m_ClearColor[2], m_ClearColor[3]); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - } - - if (g_RenderingOptions.GetPostProc()) - { - // We have to update the post process manager with real near/far planes - // that we use for the scene rendering. - m->postprocManager.SetDepthBufferClipPlanes( - m_ViewCamera.GetNearPlane(), m_ViewCamera.GetFarPlane() - ); - } - ogl_WarnIfError(); if (m_WaterManager->m_RenderWater) @@ -1367,6 +1332,23 @@ void CRenderer::RenderSubmissions(const CBoundingBoxAligned& waterScissor) } } + if (g_RenderingOptions.GetPostProc()) + { + // We have to update the post process manager with real near/far planes + // that we use for the scene rendering. + m->postprocManager.SetDepthBufferClipPlanes( + m_ViewCamera.GetNearPlane(), m_ViewCamera.GetFarPlane() + ); + m->postprocManager.Initialize(); + m->postprocManager.CaptureRenderOutput(); + } + + { + PROFILE3_GPU("clear buffers"); + glClearColor(m_ClearColor[0], m_ClearColor[1], m_ClearColor[2], m_ClearColor[3]); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + } + if (g_RenderingOptions.GetShowSky()) { m->skyManager.RenderSky(); diff --git a/source/renderer/ShadowMap.cpp b/source/renderer/ShadowMap.cpp index f3c1c21743..883538111c 100644 --- a/source/renderer/ShadowMap.cpp +++ b/source/renderer/ShadowMap.cpp @@ -599,11 +599,6 @@ void ShadowMapInternals::CreateTexture() // Set up to render into shadow map texture void ShadowMap::BeginRender() { - // HACK HACK: this depends in non-obvious ways on the behaviour of the caller - - // save caller's FBO - glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &m->SavedViewFBO); - // Calc remaining shadow matrices m->CalcShadowMatrices(); @@ -656,7 +651,7 @@ void ShadowMap::EndRender() { PROFILE("unbind framebuffer"); - pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m->SavedViewFBO); + pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); } const SViewPort vp = { 0, 0, g_Renderer.GetWidth(), g_Renderer.GetHeight() };