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

Harold Comere harold.comere at gmail.com
Fri Nov 20 01:43:55 PST 2009

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
        osg::ref_ptr <ClassC> _myElement;

        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

            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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20091120/e7f9ab0a/attachment-0001.htm>

More information about the osg-users mailing list