Don't assume default framebuffer is always zero (not true in iOS)

This commit is contained in:
Benau 2019-07-15 11:40:40 +08:00
parent c671ea8f83
commit 5a60cb4cdb
9 changed files with 17 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

@ -634,7 +634,7 @@ void COGLES2FBOTexture::bindRTT()
void COGLES2FBOTexture::unbindRTT()
{
if (ColorFrameBuffer != 0)
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, Driver->getDefaultFramebuffer());
}

View File

@ -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());
}
};

View File

@ -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;

View File

@ -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)
{

View File

@ -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);

View File

@ -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);

View File

@ -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