[osg-users] Adding input device Part 2
Jan Ciger
jan.ciger at gmail.com
Fri Apr 25 05:29:38 PDT 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Thibault Genessay wrote:
> Hi Renan
>
> On Tue, Apr 22, 2008 at 3:12 PM, Renan Mendes <renanmzmendes at gmail.com> wrote:
>> The best sollution you think, then, is using multithreads?
>>
>
> I don't know if it is the "best" solution. I've had a look at the
> first thread in the archive and saw that people here know far better
> than me the specific problem you are facing, so you might want to
> follow their conclusions.
> On the other hand, if you don't want to/can't use osgVRPN the way they
> suggest, then you could go for the multithreading approach. Your
> polling thread would be a very small class with a minimal overhead
> both in terms of implementation time and run time - OpenThreads is
> very simple to use and is already part of the OSG.
>
Even better way is to attach a node with an update callback into the
scene graph that will handle the polling for you. No need to mess with
threads and such and have problems with synchronizing access to the
device with access to the scene graph - you can modify the scene graph
from the callback safely.
Of course, this won't work right if the read from the device is
blocking, but if you are polling there is no problem.
I commonly use this approach by putting my own node with overridden
accept() method or a node with a callback in the scene graph to power
things such as physics engine or sound engine.
Jan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mandriva - http://enigmail.mozdev.org
iD8DBQFIEc6yn11XseNj94gRAtirAKCM6Mv4ADBDWrZS2cg4G6HavmzcGACguvPC
E8P5dWgmWSnYCGHixrVtPMk=
=LnJA
-----END PGP SIGNATURE-----
More information about the osg-users
mailing list