Re: [osg-users] Displaying a scene in the background of a QGraphicsView
If the cow shows and the cessna does not, it is probably an optimization step, like small feature culling. 2008/11/5 Yvon Halbwachs [EMAIL PROTECTED] Hi everybody, I managed to use osg in a Qt QGraphicsView with the information that Eric Zeremba and Rene Molenaar posted some weeks ago. I still have some troubles though... Things work fine when I display the cow.osg scene from the OpenSceneGraph example files, but nothing is displayed when I use cessna.osg. The only way to display it is to enable display lists (it is set to false by default). Anybody has a clue about what's going on? Yvon ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Displaying a scene in the background of a QGraphicsView
Hi everybody, I managed to use osg in a Qt QGraphicsView with the information that Eric Zeremba and Rene Molenaar posted some weeks ago. I still have some troubles though... Things work fine when I display the cow.osg scene from the OpenSceneGraph example files, but nothing is displayed when I use cessna.osg. The only way to display it is to enable display lists (it is set to false by default). Anybody has a clue about what's going on? Yvon ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Displaying a scene in the background of a QGraphicsView
Hi Max, My guess is that Qt is changing OpenGL state which is not being protected, and then you are mixing this with the OSG which assumes that it has complete control over OpenGL state so gets messed up by the QT changes to state, and also Qt OpenGL code is likely to be messed up by the OSG changing state. I don't know enough about the Qt's implementation here to really provide my insight. Personally I'd rather keep Qt doing Windowing and the OSG doing OpenGL. If you want to mix things then you'll need to start playing games with push and popping OpenGL state when entering the Qt OpenGl code path, and also resetting OpenGL state after leaving the OSG section. Robert. On Fri, Sep 5, 2008 at 4:16 PM, Max Pfingsthorn [EMAIL PROTECTED] wrote: Dear users, this problem has been with me for a while. I've even tried it with other graphics engines (Ogre) to no avail. As shown in this toy project at Trolltech Labs http://labs.trolltech.com/blogs/2008/06/27/accelerate-your-widgets-with-opengl/ I would like to show a scene in the background of a QGraphicsView and I was very happy that the ViewerQT class already was a QGLWidget. However, there seems to be something scaled wrong after I call viewer-frame(). Attached are a few screenshots and the code I have so far. I'm currently running Ubuntu 8.04.1 and I'm using the OSG 2.2 binaries that came with it. Beware that you need at least Qt 4.4 to compile this code. qt-osg-1.png and -2.png show how far I am at the moment. Number 2 shows the problem with scaling the window. OSG shows the scene fine in the background, but the widget I'd like to overlay is stretched. I believe the OpenGL version of QPainter draws in some normalized coordinates and the bounding box isn't properly updated. qt-osg-ok-1.png and -2.png show the same window sizes without calling viewer-frame(), and the scaling of the widget is ok. Just no scene in the background of course. I've traced the problem to osgViewer::Renderer::cull_draw(). I believe, when the geometry of the view is set, something makes Qt stop drawing correctly. In the function which calls viewer-frame() (in osgGraphicsView::drawBackground), I thought I save any sort of relevant OpenGL state, the projection matrix, model/view matrix, and even the texture matrix. After the call the viewer-frame(), I restore them again. Is there any other state that I might have overlooked which is set in the renderer? Also, do you have any idea why the Qt widget is not drawn entirely sometimes? Could it have something do to with buffer swaps? Thank you all for your help in advance! Best regards, Max Pfingsthorn ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Displaying a scene in the background of a QGraphicsView
Hello Robert, Thank you very much for your reply. My thoughts exactly. But how do I save and restore the opengl state in its entirety? I tried pushing/popping the modelview, projection and even the texture matrices around calling viewer-frame(). I also explicitly glGet'ed them and loaded them again after OSG was done in case push/pops were not matched properly inside OSG. What else is there to save in the opengl state? Best regards, Max Pfingsthorn On 5 Sep 2008, at 17:40, Robert Osfield [EMAIL PROTECTED] wrote: Hi Max, My guess is that Qt is changing OpenGL state which is not being protected, and then you are mixing this with the OSG which assumes that it has complete control over OpenGL state so gets messed up by the QT changes to state, and also Qt OpenGL code is likely to be messed up by the OSG changing state. I don't know enough about the Qt's implementation here to really provide my insight. Personally I'd rather keep Qt doing Windowing and the OSG doing OpenGL. If you want to mix things then you'll need to start playing games with push and popping OpenGL state when entering the Qt OpenGl code path, and also resetting OpenGL state after leaving the OSG section. Robert. On Fri, Sep 5, 2008 at 4:16 PM, Max Pfingsthorn [EMAIL PROTECTED] wrote: Dear users, this problem has been with me for a while. I've even tried it with other graphics engines (Ogre) to no avail. As shown in this toy project at Trolltech Labs http://labs.trolltech.com/blogs/2008/06/27/accelerate-your-widgets-with-opengl/ I would like to show a scene in the background of a QGraphicsView and I was very happy that the ViewerQT class already was a QGLWidget. However, there seems to be something scaled wrong after I call viewer-frame (). Attached are a few screenshots and the code I have so far. I'm currently running Ubuntu 8.04.1 and I'm using the OSG 2.2 binaries that came with it. Beware that you need at least Qt 4.4 to compile this code. qt-osg-1.png and -2.png show how far I am at the moment. Number 2 shows the problem with scaling the window. OSG shows the scene fine in the background, but the widget I'd like to overlay is stretched. I believe the OpenGL version of QPainter draws in some normalized coordinates and the bounding box isn't properly updated. qt-osg-ok-1.png and -2.png show the same window sizes without calling viewer-frame(), and the scaling of the widget is ok. Just no scene in the background of course. I've traced the problem to osgViewer::Renderer::cull_draw(). I believe, when the geometry of the view is set, something makes Qt stop drawing correctly. In the function which calls viewer-frame() (in osgGraphicsView::drawBackground), I thought I save any sort of relevant OpenGL state, the projection matrix, model/view matrix, and even the texture matrix. After the call the viewer-frame(), I restore them again. Is there any other state that I might have overlooked which is set in the renderer? Also, do you have any idea why the Qt widget is not drawn entirely sometimes? Could it have something do to with buffer swaps? Thank you all for your help in advance! Best regards, Max Pfingsthorn ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Displaying a scene in the background of a QGraphicsView
Hi Max, The topic of mixing OpenGL code with the OSG has been discussed many times on osg-users so have a look through the archives on this topic. glPushAttrib would also be a good keyword to search on. Robert. On Fri, Sep 5, 2008 at 6:42 PM, Max Pfingsthorn [EMAIL PROTECTED] wrote: Hello Robert, Thank you very much for your reply. My thoughts exactly. But how do I save and restore the opengl state in its entirety? I tried pushing/popping the modelview, projection and even the texture matrices around calling viewer-frame(). I also explicitly glGet'ed them and loaded them again after OSG was done in case push/pops were not matched properly inside OSG. What else is there to save in the opengl state? Best regards, Max Pfingsthorn On 5 Sep 2008, at 17:40, Robert Osfield [EMAIL PROTECTED] wrote: Hi Max, My guess is that Qt is changing OpenGL state which is not being protected, and then you are mixing this with the OSG which assumes that it has complete control over OpenGL state so gets messed up by the QT changes to state, and also Qt OpenGL code is likely to be messed up by the OSG changing state. I don't know enough about the Qt's implementation here to really provide my insight. Personally I'd rather keep Qt doing Windowing and the OSG doing OpenGL. If you want to mix things then you'll need to start playing games with push and popping OpenGL state when entering the Qt OpenGl code path, and also resetting OpenGL state after leaving the OSG section. Robert. On Fri, Sep 5, 2008 at 4:16 PM, Max Pfingsthorn [EMAIL PROTECTED] wrote: Dear users, this problem has been with me for a while. I've even tried it with other graphics engines (Ogre) to no avail. As shown in this toy project at Trolltech Labs http://labs.trolltech.com/blogs/2008/06/27/accelerate-your-widgets-with-opengl/ I would like to show a scene in the background of a QGraphicsView and I was very happy that the ViewerQT class already was a QGLWidget. However, there seems to be something scaled wrong after I call viewer-frame(). Attached are a few screenshots and the code I have so far. I'm currently running Ubuntu 8.04.1 and I'm using the OSG 2.2 binaries that came with it. Beware that you need at least Qt 4.4 to compile this code. qt-osg-1.png and -2.png show how far I am at the moment. Number 2 shows the problem with scaling the window. OSG shows the scene fine in the background, but the widget I'd like to overlay is stretched. I believe the OpenGL version of QPainter draws in some normalized coordinates and the bounding box isn't properly updated. qt-osg-ok-1.png and -2.png show the same window sizes without calling viewer-frame(), and the scaling of the widget is ok. Just no scene in the background of course. I've traced the problem to osgViewer::Renderer::cull_draw(). I believe, when the geometry of the view is set, something makes Qt stop drawing correctly. In the function which calls viewer-frame() (in osgGraphicsView::drawBackground), I thought I save any sort of relevant OpenGL state, the projection matrix, model/view matrix, and even the texture matrix. After the call the viewer-frame(), I restore them again. Is there any other state that I might have overlooked which is set in the renderer? Also, do you have any idea why the Qt widget is not drawn entirely sometimes? Could it have something do to with buffer swaps? Thank you all for your help in advance! Best regards, Max Pfingsthorn ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org