Why QOpenglWidget window loading osg for model display OpengL error when performing hibernation operation in Windows 10?
Unsolved
General and Desktop
-
The following QOpenglWidget window program address.
https://github.com/openscenegraph/osgQt
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 Robert Osfield This application is open source and may be redistributed and/or modified freely and without restriction, both in commercial and non commercial applications, as long as this copyright notice is maintained. This application is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ #include <iostream> #include <QApplication> #include <QSurfaceFormat> #include <QGridLayout> #include <QPushButton> #include <QAbstractNativeEventFilter> #include <osgDB/ReadFile> #include <osgUtil/Optimizer> #include <osg/CoordinateSystemNode> #include <osg/Switch> #include <osg/Types> #include <osgText/Text> #include <osgViewer/Viewer> #include <osgViewer/CompositeViewer> #include <osgViewer/ViewerEventHandlers> #include <osgGA/TrackballManipulator> #include <osgGA/Device> #include "osgQOpenGLWidget.h" class osgQOpengl : public QWidget { public: osgQOpengl(QWidget *parent = 0) :QWidget(parent) { setMinimumSize(800, 600); setFocusPolicy(Qt::StrongFocus); } public: void init() { // _pOsgW = new osgQOpenGLWidget(); _pOsgW->setFocus(); _layout = new QGridLayout(this); // optimize the scene graph, remove redundant nodes and state etc. QMargins marginsLayout(0, 0, 0, 0); _layout->setContentsMargins(marginsLayout);; _layout->addWidget(_pOsgW, 0, 0, 100, 100); // QObject::connect(_pOsgW, &osgQOpenGLWidget::initialized, [this] { osg::ref_ptr<osg::Node> loadedModel = nullptr; loadedModel = osgDB::readNodeFile("E:/workplace/platform-standard-5007/trunk/master/X64/bin/Debug/data/Model/ceep.ive"); loadedModel->getOrCreateStateSet()->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON); // osg::Group* root = new osg::Group(); //map->addLayer(image); // //// make the map scene graph: //osgEarth::MapNode* mapNode = new osgEarth::MapNode(map); //root->addChild(mapNode); root->addChild(loadedModel); // //osgViewer::View* pView = new osgViewer::View; //_pOsgW->getOsgViewer()->setCameraManipulator(new osgEarth::Util::EarthManipulator()); _pOsgW->getOsgViewer()->setCameraManipulator(new osgGA::TrackballManipulator); _pOsgW->getOsgViewer()->setSceneData(root); // //_pOsgW->addView(0, 0, 0, width(), height(), pView, osg::Vec4(0, 0, 0, 1)); return 0; }); } public: osgQOpenGLWidget * _pOsgW = nullptr; QGridLayout* _layout = nullptr; }; class MyAppNativeEventFilter : public QAbstractNativeEventFilter { virtual bool nativeEventFilter(const QByteArray& eventType, void* message, long* result) override { MSG* msg = reinterpret_cast<MSG*>(message); if (msg->message == WM_SYSCOMMAND) { DWORD nId = msg->wParam; if (nId == SC_SCREENSAVE || nId == SC_MONITORPOWER) { return true; } } return false; } }; MyAppNativeEventFilter filter; int main(int argc, char** argv) { //::SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED); // QSurfaceFormat format = QSurfaceFormat::defaultFormat(); #ifdef OSG_GL3_AVAILABLE format.setVersion(3, 2); format.setProfile(QSurfaceFormat::CoreProfile); format.setRenderableType(QSurfaceFormat::OpenGL); format.setOption(QSurfaceFormat::DebugContext); #else format.setVersion(2, 0); format.setProfile(QSurfaceFormat::CompatibilityProfile); format.setRenderableType(QSurfaceFormat::OpenGL); format.setOption(QSurfaceFormat::DebugContext); #endif format.setDepthBufferSize(24); //format.setAlphaBufferSize(8); format.setSamples(8); format.setStencilBufferSize(8); format.setSwapBehavior(QSurfaceFormat::DoubleBuffer); QSurfaceFormat::setDefaultFormat(format); QApplication app(argc, argv); app.installNativeEventFilter(&filter); // osgQOpengl pp; pp.init(); pp.showMaximized(); return app.exec(); }
-
RenderBin::draw() is a OSG function so I don't see what Qt can do against it. I would guess you also get the warning in a native non-Qt environment.