[osg-users] Migration from OSG 3.1.5 to 3.4.0 / Qt 4 to Qt 5

Robert Osfield robert.osfield at gmail.com
Tue Jan 5 02:03:04 PST 2016


HI Andrew

The issue revolves around the default osg::Camera constructing without
a StateSet, in this default state it doesn't set any state when you
attach it to a Viewer.  It leaves the responsibility up to you as the
developer to set up the state which is appropriate for your viewer.
Prior to OSG-3.2 a bug in osgUtil::SceneView overridded the state set
by the viewer's Camera adding in it's own global settings - this meant
you couldn't set your own which is the bug, but had a side affect of
hiding the lack of set global state by adding in some defaults, so
your application looked like it was fine even though it wasn't setting
state that it should have been doing.

The View(er) itself has osg::Camera and by default it sets up Camera
StateSet with with some defaults appropriate for viewer by calling
StateSet::setGlobalDefaults().  This means that by default the viewer
actually enables depth test etc.  However, if you replace the View(er)
Camera's without your own without the state set up in a similar way it
breaks.

The original Qt example replaced the Camera and didn't set up state so
if you ported it to OSG-3.2 or later it.  In Qt and other examples in
OSG-3.2 and later the View's Camera is used directly rather than
assigned a new one.

If you still want to assign your own Camera (something this is
actually unnecessary) you should set up the global state that you
want, sensible defaults for a 3d viewer are set up by:

   view.getCamera()->getOrCreateStateSet()->setGlobalDefaults();

If you don't do this then you application will be using OpenGL defaults.

Robert.



On 4 January 2016 at 22:57, Andrew Cunningham <andrewC at mac.com> wrote:
> [quote="robertosfield"]Hi Andrew
> The reason why z buffer etc. Is off is the your setup hasn't set it up as there is no global stateset to the camera you are passing to the Viewer.
> I have discussed this topic quite a but since OSG-3.2. Please see the archives.
> Robert. [quote]
>
> OK thanks, but my forum searching did not turn up much on this topic. Wrong keywords I suppose.
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=65940#65940
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


More information about the osg-users mailing list