From Tim George, "Currently there is a problem with using a camera with a viewport with a non 0 offset and also using an FBO. The problem is that only area made up of the viewports width and height is drawn based on an offset of 0,0 instead of using the viewports offset.

It is caused by line 991 in RenderStage.cpp:


Code:
fbo_ext->glBlitFramebuffer(
0, 0, static_cast<GLint>(_viewport->width()), static_cast<GLint>(_viewport->height()),
0, 0, static_cast<GLint>(_viewport->width()), static_cast<GLint>(_viewport->height()),
blitMask, GL_NEAREST);



which is not taking into account the viewport x and y when performing the blit. It probably should be:


Code:
fbo_ext->glBlitFramebuffer(
static_cast<GLint>(_viewport->x()), static_cast<GLint>(_viewport->y()),
static_cast<GLint>(_viewport->width()) + static_cast<GLint>(_viewport->x()), static_cast<GLint>(_viewport->height()) + static_cast<GLint>(_viewport->y()),
static_cast<GLint>(_viewport->x()), static_cast<GLint>(_viewport->y()),
static_cast<GLint>(_viewport->width()) + static_cast<GLint>(_viewport->x()), static_cast<GLint>(_viewport->height()) + static_cast<GLint>(_viewport->y()),
blitMask, GL_NEAREST);
"

Note from Robert Osfield, made small tweak to above on merge, changing the width+x to x+width to make it read more naturally.



git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14405 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield 2014-08-08 16:34:12 +00:00
parent 89786dd42a
commit af5685bf28

View File

@ -989,8 +989,10 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b
// framebuffer is multisampled then the dimension arguments are ignored
// and the whole framebuffer is always copied.
fbo_ext->glBlitFramebuffer(
0, 0, static_cast<GLint>(_viewport->width()), static_cast<GLint>(_viewport->height()),
0, 0, static_cast<GLint>(_viewport->width()), static_cast<GLint>(_viewport->height()),
static_cast<GLint>(_viewport->x()), static_cast<GLint>(_viewport->y()),
static_cast<GLint>(_viewport->x() + _viewport->width()), static_cast<GLint>(_viewport->y() + _viewport->height()),
static_cast<GLint>(_viewport->x()), static_cast<GLint>(_viewport->y()),
static_cast<GLint>(_viewport->x() + _viewport->width()), static_cast<GLint>(_viewport->y() + _viewport->height()),
blitMask, GL_NEAREST);
}
@ -1008,8 +1010,10 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT + (attachment - osg::Camera::COLOR_BUFFER0));
fbo_ext->glBlitFramebuffer(
0, 0, static_cast<GLint>(_viewport->width()), static_cast<GLint>(_viewport->height()),
0, 0, static_cast<GLint>(_viewport->width()), static_cast<GLint>(_viewport->height()),
static_cast<GLint>(_viewport->x()), static_cast<GLint>(_viewport->y()),
static_cast<GLint>(_viewport->x() + _viewport->width()), static_cast<GLint>(_viewport->y() + _viewport->height()),
static_cast<GLint>(_viewport->x()), static_cast<GLint>(_viewport->y()),
static_cast<GLint>(_viewport->x() + _viewport->width()), static_cast<GLint>(_viewport->y() + _viewport->height()),
GL_COLOR_BUFFER_BIT, GL_NEAREST);
}
}