Ignore me, I just found it...

--"J"



Guy Volckaert wrote:
Hi,

I was wondering is someone can help me with a specific problem I'm having with render-to-texture. In essence, I have a pre-render camera (i.e m_pRttCamera) that renders the entire scene to a rectangular texture (i.e m_pRttTexture). This texture is the mapped to a simple quad that fills the entire screen.
The problem occurs when the user resizes the window (note: all's well before 
resizing the window). The result of resizing the window is a fully black scene.

I know that I need to "invalidate" the texture since the window size has 
changed. The following code gets called whenever the window is resized:


Code:

void CGeViewport::ResizeRtt( )
{
    if( m_pRttTexture )
    {
// Get the size of the main camera's viewport. This is *not* // the RTT camera.
        int32 nWidth = m_pCamera->getViewport()->width();
        int32 nHeight = m_pCamera->getViewport()->height();

        // Resize the render-to-texture according to the viewports size.
        m_pRttTexture->dirtyTextureObject( );
        m_pRttTexture->setTextureSize( nWidth, nHeight );

        // Adjust the quad's texture coordinates.
        osg::Vec2Array* pTexCoords = (osg::Vec2Array*)( 
m_pRttQuad->getTexCoordArray( 0 ) );
        (*pTexCoords)[1].set( 0, 0 );
        (*pTexCoords)[1].set( nWidth, 0 );
        (*pTexCoords)[2].set( nWidth, nHeight );
        (*pTexCoords)[3].set( 0, nHeight );
    }
}




The viewport of the RTT camera is the same as the main camera. To do so, I call 
the following function:

m_pRttCamera->setViewport( m_pCamera->getViewport( ) );

I tried several things but nothing worked. Any advice would be appreciated.

Cheers,
Guy

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=14009#14009





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to