Hi,
I’m looking for the correct way to render an OpenSceneGraph object (osg::node) in a Qt Quick Item in a QML window (preferable over other qml items, but not necessary). I found several solutions/ways which cover different ways to solve this issue, but since they seem to be partially outdated and there are plenty changes in the last minor Qt version regarding OpenGL, I’m not sure which should be the best way to go.
(I’m using OSG 3.2.1 and Qt 5.3)
To my knowledge there are mainly two ways to go:
Share the GLContext with Qt, and render the object directly (e.g. in afterRendering)
Render the osg::Node to a FBO which is displayed used as texture from Qt
I’ve tried to adapt both official examples but could not get them to render my osg::node correctly.
http://doc.qt.io/qt-5/qtquick-scenegraph-openglunderqml-example.html
Added creation of a osgViewer to the paint function and set up the Viewer as embedded Window. Used osgCamera getGraphicsContext to reset and set the context. Used the viewer to render the frame (viewer-frame()) in the paint function.
http://doc.qt.io/qt-5/qtquick-scenegraph-textureinsgnode-example.html
Added creation of a osgViewer to the LogoRenderer::initialize function. Used osgCamera getGraphicsContext to reset and set the context. Used the viewer to render the frame (viewer-frame()) in the LogoRenderer::render function
In addition I’ve tried to adapt the following project to my needs:
https://github.com/preet/scratch/tree/master/qt5/qquickfboviewport
Tried the same as above, which worked until i set the viewer as embedded window.
Thank you for any hints and tips!
↧