Re: [osg-users] HUD - force refresh

2011-01-11 Thread Darren Graham
Have you tried:

hudText-setUpdateCallback(0);

or

hudText-removeUpdateCallback(bfCb);

HTH.

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] HUD - force refresh

2010-01-14 Thread Inos Tranac
Hi everyone,

I'm new around here, but I'll try to think the questions through, at least for 
the first couple of days :)

So, to the point:

I have a scene with a small HUD, and in that HUD a text that is changing based 
on some keypresses. What I'm trying to do is, in the event handler, set an 
update callback for the text, and then, immediately after that, start an 
algorithm on the scene. The callback is supposed to measure the total time of 
that algorithm. 

The images in the attachment illustrate the point.

The code of the keyboard press handler looks like this:


Code:

if ( ea.getKey()==osgGA::GUIEventAdapter::KEY_F5 )
{

if (fnn.getNode() != NULL)
{

osg::Object* obj = 
dynamic_castosg::Object*(dynamic_castosg::Geode*(fnn.getNode())-getDrawable(0));

osgText::Text* hudText = 
dynamic_castosgText::Text*(obj);

BruteForceCallback* bfCb = new 
BruteForceCallback();

hudText-setUpdateCallback(bfCb);

/*
for (int i = 0; i  10; i++)
for (int j = 0; j  2; j++)
{
int x = 0;
x += 5;
}
std::cout  Finished.  std::endl;
*/

//hudText-setUpdateCallback(NULL);

//hudText-setText(Algorithm:  + 
bfCb-getAlgorithmName()
//  + \nCamera positioned.\nTotal time:  
+ bfCb-getTimeAsString());

}


return true;
}




The for loop is a placeholder, and I've tried adding to it commands such as 
requestRedraw() and frame(), but then the program freezes. Without it, it of 
course waits until the for loop is done, and then updates the text.

I probably should have asked this question before implementing the callbacks, 
but better late than never :) , so how can I force the update of the HUD text 
periodically during the calculations? Is this a good way to do it at all? I'd 
really prefer a single-threaded program...

And one last question:
the program crashes on hudText-setUpdateCallback(NULL);
How do I remove the callback properly after the algorithm is done?


Thank you so much for any help!

Cheers,
Inos  [/code]

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




Attachments: 
http://forum.openscenegraph.org//files/afterkeypress_163.png
http://forum.openscenegraph.org//files/beforekeypress_652.png


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org