Mmmm.  Okay, that was it, I tried that before but I didn't set it directly to 
the text, I set it on the Geode I had attached the Text too..  my apologies.  
OSG is still a relatively new thing to me, as is graphics programming in 
general.  :)

Thanks for all of your help, that seemed to fix it!

Chris




robertosfield wrote:
> Hi Kris,
> 
> Set the DataVariance of the Text object to DYNAMIC, then you'd be able
> to use all threading models safely, the problem is that you are
> changing the text at the same time as it's been read by the draw
> thread.
> 
> Robert.
> 
> On Wed, Aug 19, 2009 at 2:03 PM, Kris Dale<> wrote:
> 
> > Single threading it seems to work.  My guess is that the callback is trying 
> > to access jet_yaw and jet_pitch at the same time as they're being updated.  
> > Is there a another way to get around this than single threading it?  I know 
> > in Java you can synchronize functions...  though I can't really think of a 
> > way to apply that here so I don't know why I bring it up.  Hahaha.
> > 
> > Thanks,
> > Chris
> > 
> > 
> > 
> > 
> > J.P. Delport wrote:
> > 
> > > Hi,
> > > 
> > > some things you could try:
> > > 
> > > * switch whatever viewer you have to singlethreaded and see if the
> > > problem persists. E.g.
> > > 
> > > v.setThreadingModel(osgViewer::Viewer::SingleThreaded);
> > > 
> > > * make sure the datavariance of the node is set to dynamic, e.g.
> > > 
> > > ->setDataVariance( osg::Object::DYNAMIC );
> > > 
> > > jp
> > > 
> > > 
> > > 
> > > Kris Dale wrote:
> > > 
> > > 
> > > > Morning / afternoon / evening everyone!
> > > > 
> > > > So I'll try to keep this brief enough to not be a drag to read through 
> > > > but detailed enough to be understandable.  :)  Here's a rundown of the 
> > > > situation.  I've got a HUD with text writing the yaw and pitch of a 
> > > > constantly updating object.  The HUD works perfectly when I don't try 
> > > > to update it so I'm 99.9% certain that it's not the problem.  That said 
> > > > in programming I've decided only madmen decide in certainties so I'm 
> > > > keeping an open mind.
> > > > 
> > > > The problem comes in with the update call back I've attached to the 
> > > > Geode that holds the text that's being written to the screen.  I've 
> > > > attached the code below, but the basic gist of it goes like this:
> > > > 
> > > > 1.  Convert the node to a geode.
> > > > 2.  Find the drawable attached to the geode named "textOne"
> > > > 3.  Convert the drawable to an osgText::Text object and update the text
> > > > 
> > > > I get very interesting results from this callback.  It will sometimes 
> > > > segfault almost immediately, sometimes run for several seconds without 
> > > > segfaulting, sometimes minutes.  And the entire time before it does, 
> > > > the text updates.  So it's evidently getting the reference.  Is this 
> > > > just some sort of synch issue or something?
> > > > 
> > > > 
> > > > Code:
> > > > /***********  HUD CALLBACK  **********************/
> > > > 
> > > > class updateHUDCallback : public osg::NodeCallback
> > > > {
> > > > public:
> > > > void operator()( osg::Node* node, osg::NodeVisitor* nv )
> > > > {
> > > > // convert the node* to geode*
> > > > osg::Geode* geode = node->asGeode();
> > > > 
> > > > // if we have a valid geode
> > > > if( geode ){
> > > > 
> > > > int max = geode->getNumDrawables();
> > > > int i = 0;
> > > > 
> > > > // while i < # of drawables, search
> > > > // for the drawable named "textOne"
> > > > for(int i = 0; i < max; i++){
> > > > if( geode->getDrawable(i)->getName() == "textOne" ){
> > > > break;
> > > > }
> > > > }
> > > > 
> > > > // if i==max, we either hit the end,
> > > > // or there were 0 drawables to begin
> > > > // with.  either way return.
> > > > if ( i == max ) return;
> > > > 
> > > > // convert the drawable at i to osgText*
> > > > osgText::Text* text = (osgText::Text*) geode->getDrawable(i);
> > > > 
> > > > // if we have a valid text*
> > > > if(text){
> > > > std::stringstream ss;
> > > > ss << "Yaw: " << jet_yaw << "\n" << "Pitch: " << jet_pitch << "\n";
> > > > text->setText( ss.str() );
> > > > }
> > > > 
> > > > } // end if(geode)
> > > > } // end function operator
> > > > }; // end class
> > > > 
> > > > 
> > > > 
> > > > 
> > > > I've tried adding try-catch blocks all over the place, but this doesn't 
> > > > seem to do any good.  Any suggestions?
> > > > 
> > > > ------------------
> > > > Read this topic online here:
> > > > http://forum.openscenegraph.org/viewtopic.php?p=16398#16398
> > > > 
> > > > 
> > > > 
> > > > 
> > > > 
> > > > _______________________________________________
> > > > osg-users mailing list
> > > > 
> > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > > 
> > > > 
> > > > 
> > > 
> > > --
> > > 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.  MailScanner thanks Transtec Computers for 
> > > their support.
> > > 
> > > _______________________________________________
> > > osg-users mailing list
> > > 
> > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > 
> > >  ------------------
> > > Post generated by Mail2Forum
> > > 
> > 
> > 
> > ------------------
> > Read this topic online here:
> > http://forum.openscenegraph.org/viewtopic.php?p=16423#16423
> > 
> > 
> > 
> > 
> > 
> > _______________________________________________
> > osg-users mailing list
> > 
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > 
> > 
> _______________________________________________
> osg-users mailing list
> 
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 
>  ------------------
> Post generated by Mail2Forum


------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=16439#16439





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to