Hi Manu, Its seems odd that you are getting some key events but not all, odd enough that I can't think of a failure mechanism that might explain it. I'm afraid you'll need to stick some debugging code into GraphicsWindowWin32.cpp to see what is happening with the events.
In your code shouldn't need to the setCameraWithFocus, as when you moving the mouse into the window the CameraWithFocus will be automatically set - the focus will follow the mouse, except when you click in one Camera's Viewport then drag the mouse over another Camera's Viewport, in which case the focus will stay with the original Camera till you let go of the mouse. This feature is really important for the CompositeViewer, but for a single window app is pretty irrelevant. W.r.t threading it should be OK to create the Viewer in one thread and then call realize and run the frame loop from another, you should just need to make sure that they are syncronized so that second thread doesn't start before the first one has finished. Robert. On 6/5/07, Emmanuel Roche <[EMAIL PROTECTED]> wrote:
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 osg-users@openscenegraph.net http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
_______________________________________________ osg-users mailing list osg-users@openscenegraph.net http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/