diff --git a/include/osg/GraphicsContext b/include/osg/GraphicsContext index 805bd8b96..565d3eb95 100644 --- a/include/osg/GraphicsContext +++ b/include/osg/GraphicsContext @@ -77,7 +77,8 @@ class OSG_EXPORT GraphicsContext : public Object vsync(true), useMultiThreadedOpenGLEngine(false), useCursor(true), - sharedContext(0) {} + sharedContext(0), + setInheritedWindowPixelFormat(false) {} // graphics context orginal and size int x; @@ -126,6 +127,9 @@ class OSG_EXPORT GraphicsContext : public Object GraphicsContext* sharedContext; osg::ref_ptr inheritedWindowData; + + // ask the GraphicsWindow implementation to set the pixel format of an inherited window + bool setInheritedWindowPixelFormat; }; diff --git a/src/osgViewer/GraphicsWindowWin32.cpp b/src/osgViewer/GraphicsWindowWin32.cpp index 831a64296..f6b6aad8d 100644 --- a/src/osgViewer/GraphicsWindowWin32.cpp +++ b/src/osgViewer/GraphicsWindowWin32.cpp @@ -890,7 +890,7 @@ bool Win32WindowingSystem::changeScreenSettings( const osg::GraphicsContext::Scr { case DISP_CHANGE_BADMODE : msg += " The specified graphics mode is not supported."; break; case DISP_CHANGE_FAILED : msg += " The display driver failed the specified graphics mode."; break; - case DISP_CHANGE_RESTART : msg += " The computer must be restarted for the graphics mode to work."; break; + case DISP_CHANGE_RESTART : msg += " The computer must be restarted for the graphics mode to work."; break; default : break; } @@ -1154,17 +1154,34 @@ bool GraphicsWindowWin32::setWindow( HWND handle ) } // - // Create the OpenGL rendering context associated with this window + // Check if we must set the pixel format of the inherited window // - _hglrc = ::wglCreateContext(_hdc); - if (_hglrc==0) + if (_traits.valid() && _traits->setInheritedWindowPixelFormat) { - reportErrorForScreen("GraphicsWindowWin32::setWindow() - Unable to create OpenGL rendering context", _traits->screenNum, ::GetLastError()); - ::ReleaseDC(_hwnd, _hdc); - _hdc = 0; - _hwnd = 0; - return false; + if (!setPixelFormat()) + { + reportErrorForScreen("GraphicsWindowWin32::setWindow() - Unable to set the inherited window pixel format", _traits->screenNum, ::GetLastError()); + _hdc = 0; + _hwnd = 0; + return false; + } + } + else + { + // + // Create the OpenGL rendering context associated with this window + // + + _hglrc = ::wglCreateContext(_hdc); + if (_hglrc==0) + { + reportErrorForScreen("GraphicsWindowWin32::setWindow() - Unable to create OpenGL rendering context", _traits->screenNum, ::GetLastError()); + ::ReleaseDC(_hwnd, _hdc); + _hdc = 0; + _hwnd = 0; + return false; + } } if (!registerWindowProcedure()) @@ -1974,31 +1991,6 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W } break; -#ifdef NEXT_RELEASE_ONLY - ////////////////////// - case WM_EXITSIZEMOVE : - ////////////////////// - - { - int vx = _traits->x + _screenOriginX; - int vy = _traits->y + _screenOriginY; - - int screenNum = getScreenNumberContainingWindow(_screenOriginX, _screenOriginY); - if (screenNum!=_traits->screenNum) - { - _recreateWindow = true; - - _traits->screenNum = screenNum; - int x = vx - _screenOriginX; - int y = vy - _screenOriginY; - - resized(x, y, _traits->width, _traits->height); - getEventQueue()->windowResize(x, y, _traits->width, _traits->height, _timeOfLastCheckEvents); - } - } - break; -#endif - //////////////////// case WM_KEYDOWN : case WM_SYSKEYDOWN :