Hi Alexej,

The osg::Camera's RTT/Frame buffer object support is designed around
just assigning one FBO and attachements for the lifetime of the
osg::Camera.  I haven't ever tried changing the frame buffer
object/attachment assigned dynamically so can't provide any direct
suggestions.

I would ask why you want to change the attachement, it could be that
there is an alternative way to achieve the result other than changing
the attachments.

Robert.

On 11 May 2012 15:59, Alexej Fink <dk...@gmx.net> wrote:
> Hello,
>
> unfortunately this does not work for me.
> Maybe I have to do something special in the FirstPass_ or setup the camera in 
> a special way -- I don't know.
>
> Can someone clarify is here something special missed or what is right way to 
> exchange the FBO render target the light-way (without triggering heavy 
> setCameraRequiresSetup()) ?
>
> I do it exactly the same way:
>
> Code:
>
>      if (cam && cv)
>      {
>         mImage= mRttTarget->getImage(osg::Texture::FRONTFACE);
>
>         if (mImage)
>         {
>            if (mInitialFrame) {
>               mInitialFrame= false;
>               cam->attach( osg::Camera::COLOR_BUFFER, mImage);
>            }
>            else {
> #if 0
>               cam->attach(osg::Camera::COLOR_BUFFER, mImage);
>               // heavy way, TODO: light-weight FBO render target exchange 
> possible?
>               cv->getCurrentRenderBin()->getStage()->setCameraRequiresSetUp( 
> true);
> #else
>               // cheap fbo-target exchange will not work.
>               osg::FrameBufferObject* fbo =
>                  
> cv->getCurrentRenderBin()->getStage()->getFrameBufferObject();
>               if (fbo) {
>                  
> fbo->setAttachment(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER),
>                     
> osg::FrameBufferAttachment(static_cast<osg::Texture2D*>(mRttTarget)));
>               }
> #endif
>            }
>         }
>      }
>
>
>
>
> Cheers,
> Alexej
>
>
> J.P. Delport wrote:
>> Hi Alexej & Sergey,
>>
>> also note that if you only want to change a texture attachment and the
>> formats and sizes stay the same, you can in the cull callback change it.
>> Like so:
>>
>>
>> Code:
>> void KeepHistoryPass::CameraCullCallback::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 && !hp_->FirstPass_)
>> {
>>   osg::FrameBufferObject* fbo =
>> cv->getCurrentRenderBin()->getStage()->getFrameBufferObject();
>>   if (fbo) {
>>
>>     
>> fbo->setAttachment(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER),
>>
>>     
>> osg::FrameBufferAttachment(hp_->OutTextures_[hp_->OverwriteIndex_].get()));
>>   }
>> }
>> traverse(node, nv);
>> }
>>
>>
>>
>> cheers
>> jp
>>
>>
>> --
>> This message is subject to the CSIR's copyright terms and conditions, e-mail 
>> legal notice, and implemented Open Document Format (ODF) standard.
>> The full disclaimer details can be found at 
>> http://www.csir.co.za/disclaimer.html.
>>
>> This message has been scanned for viruses and dangerous content by 
>> MailScanner,
>> and is believed to be clean.
>>
>> _______________________________________________
>> osg-users mailing list
>>
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>  ------------------
>> Post generated by Mail2Forum
>
> Code:
>
>
>
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=47658#47658
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to