I have a scene with objects colored according to external physical models.  The 
colors change as a function of model time and these colors are updated in 
shaders.  I have a time manager class that keeps track of the current model 
time and feeds that time value into my shaders using an osg uniform callback.  
I also have a keyboard listener set up to step backwards and forwards in time 
by a set amount.  When these keys are pressed the time is successully modified 
and the results change correctly in my scene.  My next step was to implement a 
simple HUD that displayed the current model time as a string.  I went through 
the HUD tutorial and successfully overlaid a text string on my scene.

Now, the problem part.  Instead of a generic text string, I wanted to have a 
callback to that string that grabbed the current time string from my time 
manager class.  I passed my time manager class by reference into my HUD class, 
then passed it again into a HUD update callback class.  For experimentation I 
tried the exact class seen in this thread:
http://forum.openscenegraph.org/viewtopic.php?t=3418
I replaced the jet_yaw and jet_pitch with a generic text string.  Everything 
else is the same.  However, as soon as my code reaches the line in the HUD 
callback that does a text->setText() command it crashes with a Access violation 
writing location 0x00000001. error message.  That error message generally means 
that I am trying to write to an uninitialized variable, but "text" was 
initialized just a few lines above and in the debugger it does seem to have 
been initialized.  The thread with that source code had advice saying to make 
the text object dynamic.  I tried making the text object dynamic in both the 
HUD callback updater and in the HUD class and my code still crashes.  

I'm a little stuck as to why this is happening but my best guess is that more 
than one function is trying to access my time manager class simultaneously.  My 
time manager class is passed by reference to my scene component's classes as 
well so that they can retrieve the time to pass to the shaders using my uniform 
callback.  Might that be the issue? I realize this is a long question but I 
figured I'd throw it out there in case there was something obvious I was doing 
wrong.  

Are there any other HUD callback tutorials that might be better suited to my 
needs?  Thanks all!

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





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

Reply via email to