From 4923c88bd03e79f68cbd0ebfa4cfc9ebb8a77ca5 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 18 Sep 2008 12:57:15 +0000 Subject: [PATCH] From Ralf Habacker, "the appended patch fixes the problem reported on http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/2008-January/006110.html. " > Using QOSGWidget - QWidget + osgViewer creating the graphics context. > > Windows Error #2000: [Screen #0] GraphicsWindowWin32::setWindow() - Unable > to create OpenGL rendering context. Reason: The pixel format is invalid. > > > > And then the following fate error pops up: > > > > The instruction at "0x014c7ef1" referenced memory at "0x000000a4", The > memory could not be "read". > > Click on Ok to terminate the program > > Click on CANCEL to debug the program > > --- src/osgViewer/GraphicsWindowWin32.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/osgViewer/GraphicsWindowWin32.cpp b/src/osgViewer/GraphicsWindowWin32.cpp index fffc08335..61e90852d 100644 --- a/src/osgViewer/GraphicsWindowWin32.cpp +++ b/src/osgViewer/GraphicsWindowWin32.cpp @@ -1140,7 +1140,13 @@ bool GraphicsWindowWin32::setWindow( HWND handle ) // // Create the OpenGL rendering context associated with this window // - + if (!setPixelFormat()) + { + reportErrorForScreen("GraphicsWindowWin32::setWindow() - Unable to set the inherited window pixel format", _traits->screenNum, ::GetLastError()); + _hdc = 0; + _hwnd = 0; + return false; + } _hglrc = ::wglCreateContext(_hdc); if (_hglrc==0) {