Hello Adrien,

Adrien wrote:
> Hi,
> I've some problem with OpenSG thread,
> In my main function I create 3 node, a geometry
> node, attach to the material group node, attach to
> the transformation node.
> At that point no problem, my object corectly appear in the scene.

>     void  GrimageThread( void* args)
>     {
>       while (true) {
> 
>         NodePtr N = G->createGeometry();   
>         GTLock->aquire();
>         G->setGeometry(N);
>         GTLock->release();
>           
>         usleep(1); // let the display loop acquire the mutex
>       }
>     }
> 
> And the last thing is to apply the thread change list in the display function 
> :
> 
>           GTLock->aquire();
>           Thread::getCurrentChangeList()->merge(*(GT->getChangeList()));
>           GT->getChangeList()->clearAll();
>           GTLock->release();

Merging the changelist does not apply the changes from it to the current
aspect. It only records the changes done on some aspect so they can be
applied together with the changes done in the current threads aspect.
Please note that I'm talking about aspects not threads these are
different concepts and OpenSG is mainly concerned with aspects (you can
read about these things here:
<http://opensg.vrsource.org/trac/wiki/Tutorial/OpenSG1/Multithreading>

You should position your locks in such a way that the setGeometry call
and rendering of the scene are mutually exclusive operations. I think
this is what crashes you here: The main thread renders the scene (but
does not hold the GTLock), the GT thread acquires the lock and sets the
geo while the rendering is in progress. The old geometry dies while it
still is queued for rendering.

        Hope it helps,
                Carsten

> Unfortunately this work a few second, where I can see my object "moving", 
> wich 
> means the geometry is correctly
> updated, but after some time it segfault.
> This problem come from the geometry. If I don't add my object to the scene 
> root 
> node but still update it no segfault .
> And if I add it, but if in the GrimageThread() function I call 
> createGeometry() 
> between the Lock aquires()
> and release() it also works. But it that case there is not point to use a 
> thread 
> as the display() loop have to wait
> the calcul of the new geometry to aquire the Lock and aplly the change list.
> 
> So why is there problems? If the main processus interupt the creation of the 
> geometry launched by the thread it's not
> a problem, as we are working on local objects not part of the scene graph, 
> when 
> the traead will get the processor again
> it will continue to construct the geometry. We only want that he is not 
> interupted when he will update the scene graph
> by removing the old node and adding the new one.
> 
> Does anyone know where this problem comes from?
> 
> Thanks,
> Adrien
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Opensg-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/opensg-users


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to