Romain,
Here's one way to do it in C++/CLI. The "control" would be the
System::Windows::Forms::Control object in which you want the OSG viewer to
render. You would then need to call viewer->frame() periodically to render
an OSG frame. If you want to port to C# in osgDotNet that is an exercise for
the reader ;) Hope this helps -gw

HWND hwnd = (HWND)control->Handle.ToPointer();

osg::ref_ptr<osg::GraphicsContext::Traits> traits =
        new osg::GraphicsContext::Traits();

traits->inheritedWindowData = new
osgViewer::GraphicsWindowWin32::WindowData( hwnd );
traits->setInheritedWindowPixelFormat = true;
traits->doubleBuffer = true;
traits->windowDecoration = false;
traits->sharedContext = 0;
traits->supportsResize = true;

RECT rect;
GetWindowRect( hwnd, &rect );
traits->x = 0;
traits->y = 0;
traits->width = rect.right - rect.left;
traits->height = rect.bottom - rect.top;

osg::ref_ptr<osg::GraphicsContext> gc =
osg::GraphicsContext::createGraphicsContext(
        traits.get() );

viewer = new osgViewer::Viewer();

osg::ref_ptr<osg::Camera> cam = new osg::Camera();
cam->setGraphicsContext( gc.get() );
cam->setViewport( new osg::Viewport( traits->x, traits->y, traits->width,
traits->height ) );
viewer->addSlave( cam.get() );


-- 
Glenn Waldron : Pelican Mapping : http://pelicanmapping.com : 703-652-4791


On Nov 19, 2007 1:08 PM, Romain Blanchais <[EMAIL PROTECTED]>
wrote:

>
> Hello,
>
> In my c# application I would like to create a Level Editor around an
> engine using osg. I need an user Interface in c# and an osg viewer in the c#
> window.
> My problem is I don't how to put the osg viewer inside my c# window. I
> think I need to set the window handle to the osg viewer with the handle off
> my c# window.
>
> I would like to know if it's possible to set the window handle (hwnd) to
> an osgviewer? I want to do that because I need to draw the osgviewer in the
> c# window.
> I know there is osgDotNet but I don't see any function which permit me to
> set the window handle.
>
>
> osgDotNet is a managed c++ wrapper of the osg c++ class. This permit to
> use osg in c# application.
> http://www.openscenegraph.org/projects/osgDotNet/wiki
>
>
> Regards
>
> _______________
> Romain Blanchais
>
> _______________________________________________
> 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