[osg-users] Displaying a scene in the background of a QGraphicsView
robert.osfield at gmail.com
Fri Sep 5 08:40:47 PDT 2008
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.
On Fri, Sep 5, 2008 at 4:16 PM, Max Pfingsthorn
<max.pfingsthorn at gmail.com> 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
> 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
> 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 at lists.openscenegraph.org
More information about the osg-users