Changed glDrawBuffer/glReadBuffer calls to use the new State::glDrawBuffers/glReadBuffers helper functions to enable lazy state updating to avoid unneccessary GL calls

This commit is contained in:
Robert Osfield 2018-03-07 17:49:40 +00:00
parent 4dac60540a
commit 4e6e0f53be

View File

@ -518,10 +518,10 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
if ( !colorAttached )
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE)
setDrawBuffer( GL_NONE, false );
setReadBuffer( GL_NONE, false );
glDrawBuffer( GL_NONE );
glReadBuffer( GL_NONE );
setDrawBuffer( GL_NONE, true );
setReadBuffer( GL_NONE, true );
state.glDrawBuffer( GL_NONE );
state.glReadBuffer( GL_NONE );
#endif
}
@ -914,10 +914,10 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE)
if( getDrawBufferApplyMask() )
glDrawBuffer(_drawBuffer);
state.glDrawBuffer(_drawBuffer);
if( getReadBufferApplyMask() )
glReadBuffer(_readBuffer);
state.glReadBuffer(_readBuffer);
#endif
}
@ -1007,8 +1007,8 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b
osg::Camera::BufferComponent attachment = it->first;
if (attachment >=osg::Camera::COLOR_BUFFER0)
{
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT + (attachment - osg::Camera::COLOR_BUFFER0));
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT + (attachment - osg::Camera::COLOR_BUFFER0));
state.glReadBuffer(GL_COLOR_ATTACHMENT0_EXT + (attachment - osg::Camera::COLOR_BUFFER0));
state.glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT + (attachment - osg::Camera::COLOR_BUFFER0));
ext->glBlitFramebuffer(
static_cast<GLint>(_viewport->x()), static_cast<GLint>(_viewport->y()),