diff --git a/src/Viewer/GraphicsWindowQt5.cpp b/src/Viewer/GraphicsWindowQt5.cpp index c9e4cd897..ae4928d53 100644 --- a/src/Viewer/GraphicsWindowQt5.cpp +++ b/src/Viewer/GraphicsWindowQt5.cpp @@ -141,6 +141,12 @@ void GLWindow::onScreenChanged() #if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)) _devicePixelRatio = screen()->devicePixelRatio(); #endif + + if (_isPrimaryWindow) { + // allow PUI and Canvas to be scaled + fgSetDouble("/sim/rendering/gui-pixel-ratio", _devicePixelRatio); + } + syncGeometryWithOSG(); } @@ -355,8 +361,6 @@ void GLWindow::wheelEvent( QWheelEvent* event ) } GraphicsWindowQt5::GraphicsWindowQt5(osg::GraphicsContext::Traits* traits) -: _realized(false) -, _updateContextNeeded(false) { _traits = traits; init(0); @@ -385,14 +389,12 @@ bool GraphicsWindowQt5::init( Qt::WindowFlags f ) //flags |= Qt::MaximizeUsingFullscreenGeometryHint; } - // create widget + // create window _window.reset(new GLWindow); _window->setFlags(flags); _window->setSurfaceType(QSurface::OpenGLSurface); _window->setFormat(traits2qSurfaceFormat(_traits.get())); _window->create(); - - _window->setTitle( _traits->windowName.c_str() ); // to get OS-dependant default positioning of the window (which is desirable), @@ -418,6 +420,10 @@ bool GraphicsWindowQt5::init( Qt::WindowFlags f ) } _window->_isPrimaryWindow = windowData->isPrimaryWindow; + if (_window->_isPrimaryWindow) { + fgSetDouble("/sim/rendering/gui-pixel-ratio", _window->_devicePixelRatio); + } + _window->setGraphicsWindow( this ); useCursor( _traits->useCursor ); @@ -760,7 +766,11 @@ void GraphicsWindowQt5::requestRedraw() void GraphicsWindowQt5::requestContinuousUpdate(bool needed) { - GraphicsWindow::requestContinuousUpdate(needed); + _continousUpdate = needed; + GraphicsWindow::requestContinuousUpdate(needed); + if (_continousUpdate) { + _window->requestUpdate(); + } } void GraphicsWindowQt5::setFullscreen(bool isFullscreen) diff --git a/src/Viewer/GraphicsWindowQt5.hxx b/src/Viewer/GraphicsWindowQt5.hxx index 7100480eb..2c5769669 100644 --- a/src/Viewer/GraphicsWindowQt5.hxx +++ b/src/Viewer/GraphicsWindowQt5.hxx @@ -112,7 +112,7 @@ protected: QSet _eventCompressor; bool _forwardKeyEvents = false; - qreal _devicePixelRatio; + qreal _devicePixelRatio = 1.0; // is this the primary (GUI) window bool _isPrimaryWindow = false; @@ -198,8 +198,9 @@ protected: QOpenGLContext* _shareContext = nullptr; bool _ownsWidget; QCursor _currentCursor; - bool _realized; - bool _updateContextNeeded; + bool _realized = false; + bool _updateContextNeeded = false; + bool _continousUpdate = false; osg::observer_ptr< osgViewer::ViewerBase > _viewer; // if true, we will generate a resize event on the next diff --git a/src/Viewer/fg_os_osgviewer.cxx b/src/Viewer/fg_os_osgviewer.cxx index 4717e6075..e54521a49 100644 --- a/src/Viewer/fg_os_osgviewer.cxx +++ b/src/Viewer/fg_os_osgviewer.cxx @@ -372,6 +372,8 @@ void fgOSInit(int* argc, char** argv) SG_LOG(SG_GL, SG_INFO, "Using Qt implementation of GraphicsWindow"); flightgear::initQtWindowingSystem(); } else { + // stock OSG windows are not Hi-DPI aware + fgSetDouble("/sim/rendering/gui-pixel-ratio", 1.0); SG_LOG(SG_GL, SG_INFO, "Using stock OSG implementation of GraphicsWindow"); } #endif