Hi John,

My guess is that the OSG is setting some OpenGL state that is being
inherited into the Qt GL drawing code.

Mixing OSG and other GL code is a little tricky as the OSG uses lazy
state updating to provide efficient use of OpenGL/graphics card, this
lazy state updating means that the OSG assumes the state is the same
going into it a new frame as it was when it left it.  The OSG also can
modify the current OpenGL state and leave it in that state, as it has
the knowledge of what the state is so can get it back to the state it
needs on the next frame.  The osg::State object associate with each
GraphicsContext is what the OSG uses to track and apply the state.

The use of lazy state updating means that you need to avoid other
OpenGL code changing the GL state without the osg::State knowing about
it.  The two ways to achieve this is to use glPushAttrib/glPopAttrib
around the non OSG GL code, or to use the osg::State::haveApplied*()
methods to tell the OSG that the non OSG GL code has modified a
particular part of OpenGL state.   The other issue, and the particular
one you are most obviously facing is that the OSG is modifying the
state and the non OSG GL code doesn't know about this so doesn't reset
it.  Two approaches you could take would be to use the
glPushAttrib/glPopAtttrib around the OSG calls, or use a StateSet at
the top of the scene graph - or the master camera's StateSet, to set
the state into a known state, and make sure that this is applied to
the osg::State right after the viewer.frame() call.

Robert.

On Wed, Oct 27, 2010 at 9:45 PM, John Doves <evage...@gmail.com> wrote:
> Hello,
> I'm having some problem with rendering osg scene into Qt application. I'm 
> setup osgViewer in single thirded and embedding:
>
>
> Code:
> viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded );
> viewer->setUpViewerAsEmbeddedInWindow(0,0, 1024, 768);
>
>
>
>
> and rendering in QGraphicsScene class with:
>
>
> Code:
> painter->beginNativePainting();
>
> glPushMatrix();
> viewer->frame();
> glPopMatrix();
>
> painter->endNativePainting();
>
>
>
>
> With simple models it rendered ok but when i use models with particles this 
> rendered with artefacts on Qt widgets. I'm attached two screenshots. Maybe i 
> must save states before frame() and restore when done?
>
> Thank you!
>
> Cheers,
> John
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=33155#33155
>
>
>
>
> _______________________________________________
> 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

Reply via email to