[osg-users] Resizing an FBO camera with OSG 3.2.0
Robert Osfield
robert.osfield at gmail.com
Mon Dec 18 03:51:55 PST 2017
HI James,
> Any hints on what else to try, to work-around this behaviour, or other
> examples of keeping a full-screen FBO camera in sync with 3.2.x, would be
> most appreciated.
>
>
> I guess no one here is using 3.2.x any more? Or people are busy, of course.
I've been away for the last 8 days, I guess others are busy too or
just don't have an answer for the problem you have as it's a very
specific usage case that most users will probably not have issues with
so won't have any specific experience to help.
I don't have any specific advice off the top of my head, the general
issues boils down to forcing recreation of FBO and Texture objects as
you can't resize existing FBO and Texture objects. The other part is
resizing the viewport and projection & view matrices.
Perhaps you can get away with implementing the OSG-3.4/master version
of osg::Camera::resizeAttachmentt(..) locally in your app :
void Camera::resizeAttachments(int width, int height)
{
bool modified = false;
for(BufferAttachmentMap::iterator itr = _bufferAttachmentMap.begin();
itr != _bufferAttachmentMap.end();
++itr)
{
Attachment& attachment = itr->second;
if (attachment._texture.valid())
{
{
osg::Texture1D* texture =
dynamic_cast<osg::Texture1D*>(attachment._texture.get());
if (texture && (texture->getTextureWidth()!=width))
{
modified = true;
texture->setTextureWidth(width);
texture->dirtyTextureObject();
}
}
{
osg::Texture2D* texture =
dynamic_cast<osg::Texture2D*>(attachment._texture.get());
if (texture && ((texture->getTextureWidth()!=width) ||
(texture->getTextureHeight()!=height)))
{
modified = true;
texture->setTextureSize(width, height);
texture->dirtyTextureObject();
}
}
{
osg::Texture3D* texture =
dynamic_cast<osg::Texture3D*>(attachment._texture.get());
if (texture && ((texture->getTextureWidth()!=width) ||
(texture->getTextureHeight()!=height)))
{
modified = true;
texture->setTextureSize(width, height,
texture->getTextureDepth());
texture->dirtyTextureObject();
}
}
{
osg::Texture2DArray* texture =
dynamic_cast<osg::Texture2DArray*>(attachment._texture.get());
if (texture && ((texture->getTextureWidth()!=width) ||
(texture->getTextureHeight()!=height)))
{
modified = true;
texture->setTextureSize(width, height,
texture->getTextureDepth());
texture->dirtyTextureObject();
}
}
}
if (attachment._image.valid() &&
(attachment._image->s()!=width || attachment._image->s()!=height) )
{
modified = true;
osg::Image* image = attachment._image.get();
image->allocateImage(width, height, image->r(),
image->getPixelFormat(), image->getDataType(),
image->getPacking());
}
}
if (modified)
{
dirtyAttachmentMap();
}
}
Robert.
More information about the osg-users
mailing list