diff --git a/lib/irrlicht/include/IVideoDriver.h b/lib/irrlicht/include/IVideoDriver.h index 6dbf74fbe..e58e0272a 100644 --- a/lib/irrlicht/include/IVideoDriver.h +++ b/lib/irrlicht/include/IVideoDriver.h @@ -1478,6 +1478,7 @@ namespace video */ virtual void convertColor(const void* sP, ECOLOR_FORMAT sF, s32 sN, void* dP, ECOLOR_FORMAT dF) const =0; + virtual u32 getDefaultFramebuffer() const =0; }; } // end namespace video diff --git a/lib/irrlicht/source/Irrlicht/CNullDriver.h b/lib/irrlicht/source/Irrlicht/CNullDriver.h index 4b745576b..162f86e7a 100644 --- a/lib/irrlicht/source/Irrlicht/CNullDriver.h +++ b/lib/irrlicht/source/Irrlicht/CNullDriver.h @@ -671,6 +671,7 @@ namespace video const c8* name=0); virtual bool checkDriverReset() {return false;} + virtual u32 getDefaultFramebuffer() const { return 0; } protected: //! deletes all textures diff --git a/lib/irrlicht/source/Irrlicht/COGLES2Texture.cpp b/lib/irrlicht/source/Irrlicht/COGLES2Texture.cpp index eab4787f2..ab40f69ea 100644 --- a/lib/irrlicht/source/Irrlicht/COGLES2Texture.cpp +++ b/lib/irrlicht/source/Irrlicht/COGLES2Texture.cpp @@ -634,7 +634,7 @@ void COGLES2FBOTexture::bindRTT() void COGLES2FBOTexture::unbindRTT() { if (ColorFrameBuffer != 0) - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, Driver->getDefaultFramebuffer()); } diff --git a/src/graphics/frame_buffer.hpp b/src/graphics/frame_buffer.hpp index b74b9bcfe..c05dcffac 100644 --- a/src/graphics/frame_buffer.hpp +++ b/src/graphics/frame_buffer.hpp @@ -21,6 +21,7 @@ #define HEADER_FRAME_BUFFER_HPP #include "graphics/gl_headers.hpp" +#include "graphics/irr_driver.hpp" #include "utils/log.hpp" #include "utils/leak_check.hpp" #include "utils/no_copy.hpp" @@ -141,11 +142,11 @@ public: return; } glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, irr_driver->getDefaultFramebuffer()); glBlitFramebuffer(0, 0, (int)m_width, (int)m_height, (int)x0, (int)y0, (int)x1, (int)y1, GL_COLOR_BUFFER_BIT, GL_NEAREST); glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, irr_driver->getDefaultFramebuffer()); } }; diff --git a/src/graphics/irr_driver.hpp b/src/graphics/irr_driver.hpp index 2d11f9cfc..4567fb05a 100644 --- a/src/graphics/irr_driver.hpp +++ b/src/graphics/irr_driver.hpp @@ -530,7 +530,9 @@ public: void uploadLightingData(); void sameRestart() { m_resolution_changing = RES_CHANGE_SAME; } - + // ------------------------------------------------------------------------ + u32 getDefaultFramebuffer() const + { return m_video_driver->getDefaultFramebuffer(); } }; // IrrDriver extern IrrDriver *irr_driver; diff --git a/src/graphics/rtts.cpp b/src/graphics/rtts.cpp index a6d43a1f5..3542b6da1 100644 --- a/src/graphics/rtts.cpp +++ b/src/graphics/rtts.cpp @@ -309,12 +309,12 @@ RTT::RTT(unsigned int width, unsigned int height, float rtt_scale, glClearColor(0., 0., 0., 0.); glClear(GL_COLOR_BUFFER_BIT); } - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getDefaultFramebuffer()); } RTT::~RTT() { - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getDefaultFramebuffer()); glDeleteTextures(RTT_COUNT, m_render_target_textures); for (FrameBuffer* fb : m_frame_buffers) { diff --git a/src/graphics/shader_based_renderer.cpp b/src/graphics/shader_based_renderer.cpp index b2834f05b..7778094c5 100644 --- a/src/graphics/shader_based_renderer.cpp +++ b/src/graphics/shader_based_renderer.cpp @@ -64,7 +64,7 @@ void ShaderBasedRenderer::prepareForwardRenderer() glClear(GL_COLOR_BUFFER_BIT); glDepthMask(GL_TRUE); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getDefaultFramebuffer()); glClearColor(clearColor.getRed() / 255.f, clearColor.getGreen() / 255.f, clearColor.getBlue() / 255.f, clearColor.getAlpha() / 255.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); @@ -564,7 +564,7 @@ void ShaderBasedRenderer::renderPostProcessing(Camera * const camera, } else if (irr_driver->getSSAOViz()) { - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getDefaultFramebuffer()); if (first_cam) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); @@ -578,7 +578,7 @@ void ShaderBasedRenderer::renderPostProcessing(Camera * const camera, } else { - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getDefaultFramebuffer()); if (first_cam) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); @@ -873,7 +873,7 @@ void ShaderBasedRenderer::renderToTexture(GL3RenderTarget *render_target, irr_driver->getActualScreenSize().Width, irr_driver->getActualScreenSize().Height); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getDefaultFramebuffer()); irr_driver->getSceneManager()->setActiveCamera(NULL); diff --git a/src/graphics/shadow_matrices.cpp b/src/graphics/shadow_matrices.cpp index 949804694..f42cc0f95 100644 --- a/src/graphics/shadow_matrices.cpp +++ b/src/graphics/shadow_matrices.cpp @@ -321,7 +321,7 @@ void ShadowMatrices::renderWireFrameFrustrum(float *tmp, unsigned i) void ShadowMatrices::renderShadowsDebug(const FrameBuffer* shadow_framebuffer, const PostProcessing *post_processing) { - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getDefaultFramebuffer()); glViewport(0, UserConfigParams::m_height / 2, UserConfigParams::m_width / 2, UserConfigParams::m_height / 2); post_processing->renderTextureLayer(shadow_framebuffer->getDepthTexture(), 0); diff --git a/src/graphics/skybox.cpp b/src/graphics/skybox.cpp index a091c9c15..5971c8426 100644 --- a/src/graphics/skybox.cpp +++ b/src/graphics/skybox.cpp @@ -297,7 +297,7 @@ void Skybox::generateSpecularCubemap() glDeleteTextures(1, &sample_texture); glDeleteBuffers(1, &sample_buffer); } - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getDefaultFramebuffer()); glDeleteFramebuffers(1, &fbo); glActiveTexture(GL_TEXTURE0); #endif