Hi, Dietmar Funck.
In order to get another texture attached you can use something like
_cam->setCullCallback( new fboAttachmentCullCB( this ) );
void fboAttachmentCullCB::operator()(osg::Node* node, osg::NodeVisitor* nv)
{
osg::Camera* fboCam = dynamic_cast<osg::Camera*>( node );
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv);
if ( fboCam && cv)
{
cv->getCurrentRenderBin()->getStage()->setFrameBufferObject(NULL); //
reset frame buffer object - see RenderStage::runCameraSetUp for details, the
fbo has to be created again
cv->getCurrentRenderBin()->getStage()->setCameraRequiresSetUp( true );
// we have to ensure that the runCameraSetUp will be entered!
}
traverse(node,nv);
}
Cheers,
Sergey.
16.02.2011, 16:48, "Dietmar Funck" <[email protected]>:
> Hi,
> I noticed the problem with first call of viewer.frame() too. This is
> happens. because meanwhile the viewer initialization - which is called by
> first call of viewer.frame() - a call to glGetString (SceneView::init() ->
> osg::isGLExtensionSupported(_renderInfo.getState()->getContextID(),""); )
> triggers exiting to the caller of viewer.frame().
> Actually nothing is rendered in the first frame.
>
> The following code works for me to get an offscreen viewer. I don't know if
> you can leave sth. out from the traits.
>
> osg::ref_ptr<osg::GraphicsContext::Traits> traits = new
> osg::GraphicsContext::Traits();
> traits->x = viewport->x(); // viewport of camera
> traits->y = viewport->y();
> traits->width = viewport->width();
> traits->height = viewport->height();
> traits->windowDecoration = false;
> traits->doubleBuffer = false;
> traits->sharedContext = NULL;
> traits->pbuffer = true;
>
> osg::GraphicsContext *graphicsContext =
> osg::GraphicsContext::createGraphicsContext(traits.get());
>
> if(!graphicsContext) {
> osg::notify(osg::NOTICE) << "Failed to create pbuffer, failing back
> to normal graphics window." << std::endl;
>
> traits->pbuffer = false;
> graphicsContext =
> osg::GraphicsContext::createGraphicsContext(traits.get());
> }
>
> viewer->getCamera()->setGraphicsContext(graphicsContext);
>
> I found another problem:
> I would like to change the textures used for render to texture. However the
> framebufferobject used by osg is only initialized once and cannot be updated
> - at least with an approach like in the osgmultiplerendertargets example.
> Camera::detach() has no effect.
>
> Best Regards
> Dietmar Funck
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=36728#36728
>
> _______________________________________________
> 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