[osg-users] Reading files and callbacks

Robert Osfield robert.osfield at gmail.com
Mon Aug 31 02:23:05 PDT 2015


Hi Tony,

The OSG uses nested callbacks rather than pre/post callbacks that Performer
uses.

Nested callbacks have the advantage that you can create local state in the
callback that can be constructed and deleted within the lifetime of the
callback, which is both more convenient, robust and thread safe than using
pre/post callbacks that attempt to achieve the same behaviour.

Nested callbacks also allow you to override the traversal behaviour -
allowing you to implement culling or multi-pass or simply custom traversal
behaviour.

This makes things that were once very hard to do in Performer really easy
and safe.

Robert.



On 31 August 2015 at 09:57, Tony Vasile <minghia at gmail.com> wrote:

> So what about the equivalent pre and post callbacks that Performer
> supports? Is it a case of copying the code in the example
>
> Code:
>
> class DrawableDrawCallback : public osg::Drawable::DrawCallback
> {
>         virtual void drawImplementation(osg::RenderInfo& renderInfo,const
> osg::Drawable* drawable) const
>         {
>             std::cout<<"draw call back - pre
> drawImplementation"<<drawable<<std::endl;
>             drawable->drawImplementation(renderInfo);
>             std::cout<<"draw call back - post
> drawImplementation"<<drawable<<std::endl;
>         }
> };
>
> class UpdateCallback : public osg::NodeCallback
> {
>         virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
>         {
>             std::cout<<"update callback - pre traverse"<<node<<std::endl;
>             traverse(node,nv);
>             std::cout<<"update callback - post traverse"<<node<<std::endl;
>         }
> };
>
>
>
>
> and putting your own calls where the pre and post calls are?
>
> Tony
>
> ------------------------
> Tony V
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=64953#64953
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150831/23f2600f/attachment-0003.htm>


More information about the osg-users mailing list