Demo: Integrating OpenSceneGraph with Qt Quick
-
wrote on 19 Aug 2013, 08:46 last edited by
I am also interested osgEarth project.
But I have not checked his work in the context of Qt Quick (Qt 5).
I hope to attend to it in the future (but still do not know when exactly).
I used osgEarth with widgets (osgQt) - try them for first. -
wrote on 19 Aug 2013, 14:17 last edited by
Thanks for your reply Konstantin.
With the help of the osgEarth guys I think I've figured it out.
When I change the frame function as such it seems to work. Maybe you could review it and include it in the demo?Thanks again!
void frame() { if (!compositeViewer.valid()) return; // Qt bug!? QOpenGLContext::currentContext()->functions()->glUseProgram(0); /* save current OpenGL state */ glPushAttrib(GL_TEXTURE_BIT|GL_LIGHTING_BIT|GL_SCISSOR_BIT|GL_STENCIL_BUFFER_BIT); //char* version = (char*)glGetString(GL_VERSION); compositeViewer->frame(); // qpainter uses vertex attribs 3,4,5 so we need to explicitly disable them: QOpenGLContext::currentContext()->functions()->glDisableVertexAttribArray(3); QOpenGLContext::currentContext()->functions()->glDisableVertexAttribArray(4); QOpenGLContext::currentContext()->functions()->glDisableVertexAttribArray(5); QOpenGLContext::currentContext()->functions()->glDisableVertexAttribArray(6); QOpenGLContext::currentContext()->functions()->glDisableVertexAttribArray(7); // qpainter requires depth testing to be off glDisable(GL_DEPTH_TEST) ; // not sure if this is required; osg changes this when using textures so I reset it to default glPixelStorei(GL_UNPACK_ALIGNMENT,4); glPopAttrib(); }
-
wrote on 13 Oct 2013, 10:02 last edited by
Hi,
In QuickWindowViewer::Hidden::frame(), the call to QOpenGLContext::currentContext() is returning null for me. The osgviewer and Qt's QML examples work perfectly well, and my machine supports FBOs (OpenGL v3.0) - any ideas why a context couldn't be created? -
wrote on 13 Oct 2013, 11:11 last edited by
I found the problem, the signal/slot connection to the failing method:
@connect(window, SIGNAL(beforeRendering()), this, SLOT(frame()));@
It should be specified as a Qt::DirectConnection as noted in the "QQuickWindow docs":http://qt-project.org/doc/qt-5.0/qtquick/qquickwindow.html#exposure-and-visibility - "Warning: As signals related to rendering might be emitted from the rendering thread, connections should be made using Qt::DirectConnection."
-
wrote on 12 Nov 2013, 22:16 last edited by
Hi Konstantin,
I recently got some more time to look into your project again. As I stated before I like the way you integrate osg and qt/qml.
I tried to extent the functionality by adding some osg pickers to allow identifying the name and type of a node underneath the mouse. This seems to work initially, but unfortunatly it doesn't after a resize of the window.
Do you have any idea why this occurs? My guess is that something does not get the new window size after a resize, but which object? Hopefully you could give me another pointer to try and get this fixed.
Thank you very much!
Rooi
-
wrote on 13 Nov 2013, 13:07 last edited by
Hi,
I managed to get the picker to work by doing the following:
Add the following lines to updateViewport()
QSize size(quickItem->boundingRect().size().toSize());
if(view->getCamera()->getGraphicsContext())
view->getCamera()->getGraphicsContext()->resized( 0, 0, size.width(), size.height() );Thanks.
-
wrote on 27 Feb 2014, 11:53 last edited by
Is someone can send me the demo ? I can't download it...
-
wrote on 11 Mar 2014, 10:36 last edited by
I am sorry, but the link to the archive is not working.
You can try to get the code via git:
@
git clone git://podsvirov.pro/osg/osgqtquick.git
@ -
wrote on 17 Apr 2014, 13:18 last edited by
Good news: a link to a screenshot and the source code in the archive is working again!
-
wrote on 7 Dec 2014, 00:38 last edited by
Hi Konstantin,
Sub: enable multisampling
Your example is really well done, Thanks. Now I want to enable multisampling, but I can not figure out how to enable it. I want to use the buffer mode.
The QOpenGLFramebufferObjectFormat.setSamples(4) does not seem to work. I don't have a very deep knowledge or osg::GraphicsWindow and its traits. But if you can guide me, I can take a look.Thanks a lot,
-
wrote on 7 Dec 2014, 00:38 last edited by
Hi Konstantin,
Sub: enable multisampling
Your example is really well done, Thanks. Now I want to enable multisampling, but I can not figure out how to enable it. I want to use the buffer mode.
The QOpenGLFramebufferObjectFormat.setSamples(4) does not seem to work. I don't have a very deep knowledge or osg::GraphicsWindow and its traits. But if you can guide me, I can take a look.Thanks a lot,
-
Hi,
I managed to get the picker to work by doing the following:
Add the following lines to updateViewport()
QSize size(quickItem->boundingRect().size().toSize());
if(view->getCamera()->getGraphicsContext())
view->getCamera()->getGraphicsContext()->resized( 0, 0, size.width(), size.height() );Thanks.
wrote on 21 Aug 2015, 02:42 last edited by@rooi
oh I am facing the same problem as you did. when I resize the windows ,it seems that the Qopenglcontext turn to null . so the fbo is initialized failed. using the method you give it does not work . i try to delete the updatafbo it works but the size of texture does not changed any more. -
wrote on 10 Sept 2015, 06:37 last edited by JKSH 9 Dec 2015, 00:27
Meet osgQtQuick 2.0!
-
wrote on 24 Nov 2015, 17:16 last edited by
Wow! More than 10 000 views :-)
It seems that many who like it!I repeat: Meet osgQtQuick 2.0!