set gl framebuffer read and write back again (#20403)

* set gl framebuffer read and write back again

* update review
This commit is contained in:
coulsonwang 2019-12-24 09:55:43 +08:00 committed by halx99
parent ed1e0744c4
commit 3541d06339
2 changed files with 21 additions and 0 deletions

View File

@ -198,6 +198,23 @@ void CommandBufferGL::applyRenderPassDescriptor(const RenderPassDescriptor& desc
if (useGeneratedFBO)
_generatedFBOBindColor = true;
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
if (_framebufferReadWriteDisabled)
{
if (useGeneratedFBO) //user-defined framebuffer
{
glDrawBuffer(GL_COLOR_ATTACHMENT0);
glReadBuffer(GL_COLOR_ATTACHMENT0);
}
else //default framebuffer
{
glDrawBuffer(GL_BACK);
glReadBuffer(GL_BACK);
}
_framebufferReadWriteDisabled = false;
}
#endif
}
else
{
@ -219,6 +236,7 @@ void CommandBufferGL::applyRenderPassDescriptor(const RenderPassDescriptor& desc
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);
_framebufferReadWriteDisabled = true;
#endif
}
CHECK_GL_ERROR_DEBUG();

View File

@ -190,6 +190,9 @@ private:
bool _generatedFBOBindColor = false;
bool _generatedFBOBindDepth = false;
bool _generatedFBOBindStencil = false;
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
bool _framebufferReadWriteDisabled = false;
#endif
GLint _defaultFBO = 0; // The value gets from glGetIntegerv, so need to use GLint
GLuint _currentFBO = 0;