From 70bfad037170aab086b3ad30293c0396b6eeb603 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 24 Jan 2014 17:06:32 +0000 Subject: [PATCH] From Aurelien Albert, "In the "apply" method of osg::FrameBufferObject, the draw buffers are always enabled, even if the target is only "READ_FRAMEBUFFER". This can lead to inconsistency if you bind a framebuffer with multiple attachments in DRAW mode and then a framebuffer with different attachment count in READ mode (for example to manually "blit" from a FBo to another). On some ATI cards (at least RADEON HD) this also leads to an "incomplete " FBO status I've added a test to enable drawbuffers only if target is "DRAW" or "READ_DRAW", this solves my problems on ATI cards." --- src/osg/FrameBufferObject.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/osg/FrameBufferObject.cpp b/src/osg/FrameBufferObject.cpp index ee06df812..062ee6428 100644 --- a/src/osg/FrameBufferObject.cpp +++ b/src/osg/FrameBufferObject.cpp @@ -914,16 +914,19 @@ void FrameBufferObject::apply(State &state, BindTarget target) const ext->glBindFramebuffer(target, fboID); // enable drawing buffers to render the result to fbo - if (_drawBuffers.size() > 0) + if ( (target == READ_DRAW_FRAMEBUFFER) || (target == DRAW_FRAMEBUFFER) ) { - GL2Extensions *gl2e = GL2Extensions::Get(state.getContextID(), true ); - if (gl2e && gl2e->isDrawBuffersSupported()) + if (_drawBuffers.size() > 0) { - gl2e->glDrawBuffers(_drawBuffers.size(), &(_drawBuffers[0])); - } - else - { - OSG_WARN <<"Warning: FrameBufferObject: could not set draw buffers, glDrawBuffers is not supported!" << std::endl; + GL2Extensions *gl2e = GL2Extensions::Get(state.getContextID(), true ); + if (gl2e && gl2e->isDrawBuffersSupported()) + { + gl2e->glDrawBuffers(_drawBuffers.size(), &(_drawBuffers[0])); + } + else + { + OSG_WARN <<"Warning: FrameBufferObject: could not set draw buffers, glDrawBuffers is not supported!" << std::endl; + } } }