Hi,
It's been 3 days that I'm trying to integrate Osg inside a Wpf Application.
I would like to integrate an osgviewer using a class that extends HwndHost
(defined in System.Windows.Runtime.InteropServices) as shown in an article
attached to a Forum Topic about WPF (see Ref)
Rapidly: I wrote the BuildWindowCore implementation but I'm getting a
SEHException every time that I try to create the Graphic Context:
Code:
virtual HandleRef BuildWindowCore(HandleRef hwndParent) override {
RECT DrawingCanvas;
HWND WindowHandle =
CreateWindowEx(0,_className, _windowName, _dwStyle, 0, 0, 100, 100, (HWND)
hwndParent.Handle.ToPointer(), 0, _hInstance, 0 );
GetWindowRect(WindowHandle, &DrawingCanvas);
osg::ref_ptr<osg::Referenced> windata = new
osgViewer::GraphicsWindowWin32::WindowData(WindowHandle);
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new
osg::GraphicsContext::Traits;
// Setup Graphic Context
traits->x = 0;
traits->y = 0;
traits->width = DrawingCanvas.right - DrawingCanvas.left;
traits->height = DrawingCanvas.bottom - DrawingCanvas.top;
traits->windowDecoration = false;
traits->doubleBuffer = true;
traits->sharedContext = 0;
traits->inheritedWindowData = windata;
// Pixel Format Descriptor
PIXELFORMATDESCRIPTOR pixelFormat = {
sizeof(PIXELFORMATDESCRIPTOR), 1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA, 32,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
24, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0
};
// Get the device context for the Win32 handle to the control
HDC hdc = ::GetDC(WindowHandle);
// Set the pixel format on the device context
int pixelFormatIndex = ::ChoosePixelFormat(hdc, &pixelFormat);
::SetPixelFormat(hdc, pixelFormatIndex, &pixelFormat)
// Create an Open Scene Graph graphics context
osg::ref_ptr<osg::GraphicsContext> gc =
osg::GraphicsContext::createGraphicsContext(traits);
return HandleRef(this, IntPtr(WindowHandle));
}
Do you have some ideas on how solve my problem?
Am I doing something wrong?
Thank you!
Have a nice day!,
Chris
Ref: forum openscenegraph, viewtopic with t=3279
(sorry but I cant submit links now)
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=35946#35946
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org