[osg-users] Adding input device Part 2

Thibault Genessay tibogens at gmail.com
Tue Apr 22 05:56:38 PDT 2008


Hi Renan

On Tue, Apr 22, 2008 at 2:36 PM, Renan Mendes <renanmzmendes at gmail.com> wrote:
> Hi,
>
>      As some of you may remember, i was trying to add a new input device to
> my OSG application. This device was the SpaceNavigator. I had access to the
> code that gets the 3D coordinates from it any time it is activated. But,
> when it is idle, that code makes my application stop and wait for any signal
> from SN. I was inserting that loop in the event type FRAME. But, as you may
> imagine, when I stopped moving with SN, my application entered that waiting
> stage, and the regular cycles of traversal, culling and drawing were
> blocked.
>       Someone else suggested that I added this device in a new Event Handler
> class. Is that right? How do I do that, exactly? Any examples?

Could not you poll your device in a separate thread ? You could then
populate a (mutex protected) list with all events you receive from
your device. The main OSG loop would in turn check for pending events
each frame (locking the mutex, checking if any events need to be
processed then releasing it).
This way if the call that queries the device blocks, it won't make
your application stall - only the polling thread will.

Regards

Thibault


More information about the osg-users mailing list