Okay... I made some more tests:

1) Preparing everything in thread 1 and calling realize() here, before using
thread 2 for run() is not a good solution (still not receiving Key_Up events
then !!).

2) Preparing everything in thread 2 and running there works "partially"
(receiving the Key_* events correctly....)... yet, in fact, in thread 1 I
used to prepare everything, and also assign the scene data... if I keep it
like this, nothing is displaying (only a blue screen: this mean at least
that the viewer REALLY HAS a scene data assigned (or run() would return
immediately no ?) )... if I also assign the data in thread 2, everything is
normal... but doing things this way is completely useless since ALL is done
in thread 2, the thread 1 is not used any more and the multi threading
scheme becomes obsolete... :-(... snif !

Could I be needing something like a "mutable" or "volatile" reference to my
viewer object (I not used to those keywords yet sorry lol...) ?

Manu.


2007/6/5, Emmanuel Roche <[EMAIL PROTECTED]>:

In fact I guess this is still linking to the amulti threading issue : I'm
building by viewer in a Thread n°1 (-> one call to createGraphicsContext()),
then I call run() in a second thread (--> call realize())...

what is the good solution in this situation ? should I prepare everything
in thread 1, call realize() here and only then call run() or frame() in
thread 2 ? or should I do everything in thread 2 only ?

I'm still not understanding what's happening :-)...

Manu.


2007/6/5, Emmanuel Roche <[EMAIL PROTECTED]>:
>
> Hello there !!
>
>
> I'm playing a bit with this new viewer and noticed a strange behavior :
>
> under windows, when I use a default fullscreen viewer I receive all key
> events normally in a GUIEventHandler I added to my Viewer, but, if I try to
> build a windowed viewer, adding the following code:
>
>     {
>         osg::ref_ptr<osg::GraphicsContext::Traits> traits = new
> osg::GraphicsContext::Traits;
>         traits->x = 50;
>         traits->y = 50;
>         traits->width = 640;
>         traits->height = 480;
>         traits->windowDecoration = true;
>         traits->doubleBuffer = true;
>         traits->sharedContext = 0;
>
>         osg::ref_ptr<osg::GraphicsContext> gc =
> osg::GraphicsContext::createGraphicsContext( traits.get());
>
>
>         osg::ref_ptr<osg::Camera> camera = new osg::Camera;
>         camera->setGraphicsContext(gc.get());
>         camera->setViewport(new osg::Viewport(0,0, traits->width,
> traits->height));
>         GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
>         camera->setDrawBuffer(buffer);
>         camera->setReadBuffer(buffer);
>
>         // add this slave camra to the viewer, with a shift left of the
> projection matrix
>         //viewer.setCamera( camera.get());
>
>         viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd());
>         viewer.setCameraWithFocus(camera.get());
>     }
>
>
> (taken mainly from osgwindows sample...)
> then my GUIEventHandler is not receiving the Key_Up, Down , Left and
> Right events (at least !) any more... :-( (but is still receiving normal
> ascii keys like 'a' or 'q' for example)... any idea what I'm missing ?
>
> Manu.
>
>
>

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to