[osg-users] osg::Drawable::DrawCallback issue

Robert Osfield robert.osfield at gmail.com
Fri Nov 20 09:03:33 PST 2009


Hi Harold,

The most likely issue is that you are running the view multi-threaded,
but not setting the DataVariance on the Text field to DYNAMIC - do
this and you'll prevent the next frame from advancing before it's
finished rendering the dynamically updated parts of the scene.

Robert.

On Fri, Nov 20, 2009 at 9:43 AM, Harold Comere <harold.comere at gmail.com> wrote:
> Hi all,
>
> I am currently experiencing some issues to update often the text of an
> osgText::Text. I m working with osg 2.8.1.
>
> While draging the mouse i need to update the text of an osgText, so this
> update is called very often.
> So i have done a class inherating of osg::Drawable::DrawCallback, wich i
> attach to my osgText::Text as an update callback :
> And in the following code ClassC is a class inherating of osg::Geode and
> containing the osgText.
>
> When the mouse is draging i set a flag _needUpdate of my ClassC class to
> true, then text is updated in the callback if needed.
>
>     class TextDrawCallback : public virtual osg::Drawable::DrawCallback
>     {
>     private:
>         osg::ref_ptr <ClassC> _myElement;
>
>     public:
>         TextDrawCallback ( ClassC * element ) : _myElement ( element ) { }
>
>         virtual void drawImplementation ( osg::RenderInfo& renderInfo, const
> osg::Drawable * drawable ) const
>         {
>              // if the flag is to true
>              if ( _myElement->getNeedUpdate() )
>              {
>                   std::string newValue = anything computed
>                   _myElement->getOsgText()->setText( newValue );
>                   _myElement->setNeedUpdate( false ); // no need update
> anymore
>              }
>
>             drawable->drawImplementation ( renderInfo );
>         }
>     };
>
> This works well under linux but make sometimes crashes under windows XP. The
> crash appear in the code called by
>             drawable->drawImplementation ( renderInfo );
> but i cant find out the main reason.
>
> Did i something wrong with this callback ?
>
> Thanks for your attention.
> Regards,
> Harold
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>


More information about the osg-users mailing list