Here is the code snippet. All the viewer stuff is created from within the
dll I am loading and the main thread is forwarding messages to it

osg::ref_ptr<osgDB::DynamicLibrary> dll =
osgDB::DynamicLibrary::loadLibrary("bin/ig/KtIGLibOSG/KtIGLibOSG.dll");
if (dll.get())
{
osgDB::DynamicLibrary::PROC_ADDRESS proc =
dll->getProcAddress("createIGLib");
 if (proc)
{
createIGLibFn *fn = (createIGLibFn*)proc;
 lib = fn(0,0);
}
}

lib->init();

while (!lib->isDone())
{
#ifdef WIN32
MSG msg;
if (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
 {
::GetMessage(&msg, NULL, 0, 0);
lib->postMessage((void*)&msg);
 }
#endif
}

void KtIGLibOSG::postMessage(void* msg)
{
if (mViewer.valid())
{
 osgViewer::CompositeViewer::Windows wins;
mViewer->getWindows(wins);
 #ifdef WIN32
osgViewer::GraphicsHandleWin32 *hdl =
dynamic_cast<osgViewer::GraphicsHandleWin32*>(wins.at(0));
 if(hdl)
{
MSG* message = (MSG*)msg;
 WNDPROC fWndProc = (WNDPROC)::GetWindowLong(hdl->getHWND(), GWL_WNDPROC);
fWndProc(hdl->getHWND(), message->message, message->wParam,
message->lParam);
 }
#endif
}
}

hope it helps

Nick

http://www.linkedin.com/in/tnick
Sent from Izmit, 41, Turkey

On Mon, Jan 4, 2010 at 9:06 AM, J.P. Delport <[email protected]> wrote:

> Hi Nick,
>
>
> Trajce Nikolov wrote:
>
>> Hi J.P.
>>
>> exactly, the same issue. I made it work though with dispatching messages
>> from the main thread to the other from the dll and it works this way.
>>
>
> Could you expand on how you do this. I'd like to forward to our Windows
> developer.
>
> thanks
> jp
>
>
>> Nick
>>
>> http://www.linkedin.com/in/tnick
>> Sent from Izmit, 41, Turkey
>>
>> On Mon, Jan 4, 2010 at 8:48 AM, J.P. Delport <[email protected]<mailto:
>> [email protected]>> wrote:
>>
>>    Hi,
>>
>>    I've had similar issues. See this thread:
>>    http://thread.gmane.org/gmane.comp.graphics.openscenegraph.user/50527
>>
>>    jp
>>
>>    Trajce Nikolov wrote:
>>
>>        Hi Wojtek,
>>
>>        the same setup I have here, all in dll. Not working though,
>>        windows7. I had to do some hacks with the win32 messaging to
>>        make it work
>>
>>        Nick
>>
>>        http://www.linkedin.com/in/tnick
>>        Sent from Devlet, Ankara, Turkey
>>
>>        On Mon, Dec 21, 2009 at 11:49 AM, Wojciech Lewandowski
>>        <[email protected] <mailto:[email protected]>
>>        <mailto:[email protected] <mailto:[email protected]>>>
>>
>>        wrote:
>>
>>           Hi Guys
>>
>>           I doubt your problem is directly related to DLL use. We have
>>        a code
>>           at the company where allmost all OSG stuff including osgViewer
>>           creation is loaded as dynamic DLL plugins. Its built with VS
>> 2008
>>           Express. All works correctly and we see no problem with
>>        window focus
>>           or similar things. I suspect something might get lost in
>>        translation
>>           to DLL. Mangled args passed to viewer, mixed library models,
>>           overrriden HINSTANCE or somethin like this...( these are very
>>        fuzzy
>>           thoughts, if I was to elaborate I would not be able to tell
>>        how they
>>           could directly affect DLL window setup).
>>
>>           Cheers,
>>           Wojtek
>>
>>           --------------------------------------------------
>>           From: "Robert Osfield" <[email protected]
>>        <mailto:[email protected]>
>>           <mailto:[email protected]
>>        <mailto:[email protected]>>>
>>
>>           Sent: Monday, December 21, 2009 10:21 AM
>>           To: "OpenSceneGraph Users"
>>        <[email protected]
>>        <mailto:[email protected]>
>>           <mailto:[email protected]
>>        <mailto:[email protected]>>>
>>
>>           Subject: Re: [osg-users] viewer loaded from dll not
>>        responsive to events
>>
>>
>>               Hi Nick,
>>
>>               I'm no windows programmers, but vaguely recall a
>>        restriction on
>>               events
>>               and the main thread, osgViewer has code built in to cope
>>        with this,
>>               but don't recall any issues with loading a viewer from a
>> dll.
>>
>>               The best platform for handling really flexible window
>>        creation
>>               is the
>>               oldest one we support... X11.... allows you great control
>>        over
>>               events
>>               and is far better than Windows and OSX for this.  Alas
>>        sometimes
>>               technologies go backwards overtime....
>>
>>               Robert.
>>
>>               On Sun, Dec 20, 2009 at 11:01 PM, Trajce Nikolov
>>               <[email protected]
>>        <mailto:[email protected]>
>>        <mailto:[email protected]
>>        <mailto:[email protected]>>> wrote:
>>
>>                   Hi,
>>                   I am loading my viewer from a dll and as the topic
>>        says, it
>>                   does not respond
>>                   to any events. Windows platform. Any ideas?
>>                   There is a way I think to put message hooks but it is
>>        more
>>                   then a hack then
>>                   a real solution
>>                   Thanks
>>                   Nick
>>
>>                   http://www.linkedin.com/in/tnick
>>
>>                   _______________________________________________
>>                   osg-users mailing list
>>                   [email protected]
>>        <mailto:[email protected]>
>>                   <mailto:[email protected]
>>        <mailto:[email protected]>>
>>
>>
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>
>>               _______________________________________________
>>               osg-users mailing list
>>               [email protected]
>>        <mailto:[email protected]>
>>               <mailto:[email protected]
>>        <mailto:[email protected]>>
>>
>>
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>
>>
>>           _______________________________________________
>>           osg-users mailing list
>>           [email protected]
>>        <mailto:[email protected]>
>>           <mailto:[email protected]
>>        <mailto:[email protected]>>
>>
>>
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>
>>
>>
>>  ------------------------------------------------------------------------
>>
>>        _______________________________________________
>>        osg-users mailing list
>>        [email protected]
>>        <mailto:[email protected]>
>>
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>
>>    --    This message is subject to the CSIR's copyright terms and
>>    conditions, e-mail legal notice, and implemented Open Document
>>    Format (ODF) standard. The full disclaimer details can be found at
>>    http://www.csir.co.za/disclaimer.html.
>>
>>    This message has been scanned for viruses and dangerous content by
>>    MailScanner, and is believed to be clean.  MailScanner thanks
>>    Transtec Computers for their support.
>>
>>
>>    _______________________________________________
>>    osg-users mailing list
>>    [email protected]
>>    <mailto:[email protected]>
>>
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> osg-users mailing list
>> [email protected]
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>
> --
> This message is subject to the CSIR's copyright terms and conditions,
> e-mail legal notice, and implemented Open Document Format (ODF) standard.
> The full disclaimer details can be found at
> http://www.csir.co.za/disclaimer.html.
>
> This message has been scanned for viruses and dangerous content by
> MailScanner, and is believed to be clean.  MailScanner thanks Transtec
> Computers for their support.
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to