Hi.
Not only because of my (still not working) video textures, I've got the
strong feeling that I have some deficits understanding the whole Threads
and Aspects thing, maybe someone can clearify this for me.
The application I'm working on is entirely based on plugins, that may
open their own threads for their purposes like decoding video or
evaluating VRML coordinate interpolators (libOpenSGVRMLAnimation). As I
don't know how many of them exist and on which aspect they are working
on, I've got a utility class (System), that allows to register a thread
and (if needed) barriers.
void System::registerSyncThread(OSG::Thread *thread){
_threads.push_back(thread);
}
void System::registerSyncBarrier(OSG::Barrier *barrier){
_barriers.push_back(barrier);
}
If a plugin needs its own thread, I start it and register the
corresponding pointer in System:
OSG::Thread
*thread=dynamic_cast<OSG::Thread*>(OSG::ThreadManager::the()->getThread("video"));
thread->runFunction(&playFunc,ASPECT_ZERO_OR_ONE,(void*)(this));
System::the()->registerSyncThread(thread);
Before I draw the scene (this happens in the Appplication thread), I
call the following function:
void System::mergeAndClearChangeLists(){
vector<OSG::Barrier*>::iterator bIt;
vector<OSG::Thread*>::iterator it;
for(bIt=_barriers.begin();bIt!=_barriers.end();++bIt){
(*bIt)->enter(2);
}
for(it=_threads.begin();it!=_threads.end();++it){
//applyAndClear? merge && clearAll?!
//No matter what I tried, it failed in some way, so please read on....
}
for(bIt=_barriers.begin();bIt!=_barriers.end();++bIt){
(*bIt)->enter(2);
}
}
After drawing the scene, I call Thread::getCurrentChangeList()->clearAll();
Ok, I hope it's clear now what I try to achieve. Let's summarize some of
the problems.
In the above example (this is from my video content, see my last posting
for more code), I create things like a TextureChunk and a Plane in the
main thread and change it in the new thread. This works if (and only if):
- the aspect of the new thread is the same like the aspect of the main
thread (else it crashes with a segfault)
- System::mergeAndClearChangeLists does
OSG::Thread::getCurrentChangeList()->merge(*((*it)->getChangeList()));
(*it)->getChangeList()->clearAll();
- only if I don't use Cluster/Server Rendering (if I do, I see the
first Frame of the video on the plane but no updates)
Some questions in addition:
* If I call thread->getAspect(), the result changes according to the
thread I'm using: If I call it in the System::mergeAndClearChangeLists
func (which is running in Aspect 0) it's 0 for all threads. If I call it
in the Function that I start with thread->runFunction it's correct. Why?
Isn't it possible to check on which aspect a thread is working from
another one?
* How can I handle all my threads (no matter which aspect they use) in
System::mergeAndClearChangeLists?
* Thread::merge? Thread::apply? When do I have to use what?
Although I'm working quite some time now with OpenSG, this is still very
confusing for me. Can someone help me out?!
Thanks & regards,
Dominik
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users