hi OpenSg friends,
i am doing a little application that renders the scene on a texture
and then uses that texture to assemble the final output.
With an eye to the speed of the application,
i am using an fboviewport:
void createFBO ()
{
m_iFBOWidth = getWidth ();
m_iFBOHeight = getHeight ();
m_iTexWidth = osg::osgnextpower2( m_iFBOWidth );
m_iTexHeight = osg::osgnextpower2( m_iFBOHeight );
m_pFirstStageTexture = osg::TextureChunk::create();
osg::ImagePtr image = osg::Image::create();
beginEditCP(image);
image->set(osg::Image::OSG_RGBA_PF, m_iTexWidth, m_iTexHeight);
endEditCP(image);
beginEditCP(m_pFirstStageTexture);
m_pFirstStageTexture->setMinFilter(GL_NEAREST);
m_pFirstStageTexture->setMagFilter(GL_NEAREST);
// m_pFBOTexture->setWrapR( GL_CLAMP_TO_EDGE );
// m_pFBOTexture->setWrapS( GL_CLAMP_TO_EDGE );
m_pFirstStageTexture->setTarget(GL_TEXTURE_2D);
m_pFirstStageTexture->setInternalFormat(GL_RGBA8);
m_pFirstStageTexture->setImage(image);
endEditCP(m_pFirstStageTexture);
m_pFBO = osg::FBOViewport::create();
osg::GradientBackgroundPtr gb = osg::GradientBackground::create();
beginEditCP(gb);
gb->addLine(osg::Color3f(0.0, 0.0, 0.7), 0.0);
gb->addLine(osg::Color3f(1.0, 1.0, 0.0), 1.0);
endEditCP(gb);
beginEditCP(m_pFBO);
m_pFBO->setStorageWidth(m_iTexWidth);
m_pFBO->setStorageHeight(m_iTexHeight);
m_pFBO->setBackground(gb);
m_pFBO->setCamera(m_pCamera);
m_pFBO->setParent(m_pOSGWidget->getWindow());
m_pFBO->getTextures().push_back(m_pFirstStageTexture);
m_pFBO->setRoot(m_pMgr->getRoot ());
m_pFBO->setSize(0, 0, m_iFBOWidth-1, m_iFBOHeight-1);
m_pFBO->setReadBuffer (false);
m_pFBO->setFboOn (true);
endEditCP(m_pFBO);
}
and the application renders on the texture as explected.
However, if i resize the window and the fboviewport,
the image that i get from the fbo is just the last image rendered
repeated to fit the new image size.
I resize the fbo via:
resize
{
m_iFBOWidth = getWidth ();
m_iFBOHeight = getHeight ();
m_iTexWidth = osg::osgnextpower2( m_iFBOWidth );
m_iTexHeight = osg::osgnextpower2( m_iFBOHeight );
for( unsigned int nt = 0; nt < m_pFBO->getTextures().getSize(); ++ nt )
{
osg::TextureChunkPtr tex = m_pFBO->getTextures()[nt];
beginEditCP (tex);
beginEditCP(tex->getImage());
tex->getImage()->set(tex->getImage()->getPixelFormat(),
m_iTexWidth, m_iTexHeight );
endEditCP(tex->getImage());
endEditCP (tex);
}
beginEditCP(m_pFBO);
m_pFBO->setSize(0, 0, m_iFBOWidth-1, m_iFBOHeight-1);
m_pFBO->setStorageWidth(m_iTexWidth);
m_pFBO->setStorageHeight(m_iTexHeight );
endEditCP(m_pFBO);
}
is there something else that i should consider?
thanks for any hints
E.
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users