Hello,
I am doing a render to texture similar to the osgprerender example. I render the texture on a
quad that fits the viewport. I'd like to be able to change my texture resolution when the user
resizes the viewport. Can you just resize everything (viewport, texture, quad) in a callback ?
Do you need to re-attach the texture or stipulate that the quad geometry is somehow dirty ?
I tried this in a callback but it looks like the texture is not resized:
// change camera viewport, RTT textures resolution, and quad size for all passes
for(unsigned int i=0; i<m_vPassList.size(); i++)
{
// resize main cam viewport
if(m_vPassList[i]->m_RttCam.valid())
{
m_vPassList[i]->m_RttCam->setViewport(0, 0,
static_cast<int>(m_uiAppWindowRes.x()), static_cast<int>(m_uiAppWindowRes.y()));
}
// resize RTT texture size
if(m_vPassList[i]->m_RttTex.valid())
{
osg::TextureRectangle *pTex = dynamic_cast<osg::TextureRectangle *>(m_vPassList[i]->m_RttTex.get());
if(pTex != NULL && m_vPassList[i]->m_RttCam.valid())
{
pTex->setTextureSize(static_cast<int>(m_uiAppWindowRes.x()), static_cast<int>(m_uiAppWindowRes.y()));
m_vPassList[i]->m_RttCam->attach(osg::CameraNode::COLOR_BUFFER, pTex);
}
}
// resize quad
if(m_vPassList[i]->m_Quad.valid())
{
osg::Geometry* pGeomQuad = dynamic_cast<osg::Geometry*>(m_vPassList[i]->m_Quad->getDrawable(0));
assert(pGeomQuad);
osg::Vec3Array* pQuadVerts = dynamic_cast<osg::Vec3Array*>(pGeomQuad->getVertexArray());
assert(pQuadVerts);
(*pQuadVerts)[0] = (osg::Vec3(0, 0, 0));
(*pQuadVerts)[1] = (osg::Vec3(m_uiAppWindowRes.x(), 0, 0));
(*pQuadVerts)[2] = (osg::Vec3(m_uiAppWindowRes.x(), 0, m_uiAppWindowRes.y()));
(*pQuadVerts)[3] = (osg::Vec3(0, 0, m_uiAppWindowRes.y()));
}
}
Any suggestion would be greatly appreciated :)
guillaume
_______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
