Hi Carstern,
First of all, thanks for the help. As i said, i'm trying to render to
texture using fboviewport, but with no success. I took a look on
simplestage, but i'm not sure if it will fit to my needs. My objective is to
render the screen to a texture buffer without modifing the aplication
scene. Also, i need a viewport with a different size from the aplication,
and the camera will be pointing to other point.
To do this, i create the following code. This is not exactly what i need to
do, but it's only for testing:
CreateFboViewport( OSG::Node* scene, int width, int height )
{
// Set up the scene to be rendered on the texture buffer
_fboSceneRoot = OSG::Node::create();
_fboSceneRoot->setCore( OSG::Group::create() );
_fboSceneRoot->addChild( scene );
// create camera beacon. The transform core will be set on updateCubeMap
_cameraBeacon = OSG::Node::create();
_fboSceneRoot->addChild( _cameraBeacon );
_camera = OSG::PerspectiveCamera::createEmpty();
_camera->setBeacon( _cameraBeacon );
_camera->setFov( OSG::osgDegree2Rad( 90.0 ) );
_camera->setAspect( width / height );
// create the texture where the scene will be rendered
_fboTexImg = OSG::Image::create();
_fboTexImg->set( OSG::Image::OSG_RGBA_PF, width, height );
_fboTex = OSG::TextureObjChunk::create();
_fboTex->setImage( _fboTexImg );
// create a texture buffer
_texBuf = OSG::TextureBuffer::create();
_texBuf->setTexture( _fboTex );
_texBuf->setReadBack( true );
// create the fbo
_fbo = OSG::FrameBufferObject::create();
_fbo->setWidth ( width );
_fbo->setHeight( height );
_fbo->setPostProcessOnDeactivate( true );
// set the texture buffer as render target
_fbo->setColorAttachment( _texBuf, 0 );
_fbo->editMFDrawBuffers()->clear();
_fbo->editMFDrawBuffers()->push_back( GL_COLOR_ATTACHMENT0_EXT );
// create the fboviewport
_fboViewport = OSG::FBOViewport::createEmpty();
_fboViewport->setFrameBufferObject( _fbo );
_fboViewport->setSize( 0, 0, width, height );
_fboViewport->setCamera( _camera );
_fboViewport->setRoot( _fboSceneRoot );
OSG::SolidBackgroundRecPtr bg = OSG::SolidBackground::create();
bg->setColor(OSG::Color3f(1.0f, 0.0f, 0.0f));
_fboViewport->setBackground( bg );
// create window e renderaction
_window = OSG::PassiveWindow::create();
_window->init();
_window->addPort( _fboViewport );
_renderAction = OSG::RenderAction::create();
}
updateFboTexture( OSG::Camera* camera )
{
_camera->setFar( camera->getFar() );
_camera->setNear( camera->getNear() );
_cameraBeacon->setCore( camera->getBeacon()->getCore() );
_window->render( _renderAction );
_fboTexImg->write( "fboTest.png" );
}
I call CreateFboViewport one time to create the fboviewport and then, when i
want to save the screen, i call updateFboTexture. When doing this, the saved
image is alway black. What am i doing wrong?
Thanks,
Daniel
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users