[osg-users] osgViewer/Renderer ctor set wrong defaults for SceneView

Robert Osfield robert.osfield at gmail.com
Wed Feb 3 03:43:52 PST 2016


Hi Christian,

On 3 February 2016 at 10:32, Christian Ehrlicher <Ch.Ehrlicher at gmx.de> wrote:
> Hi,
>
> I thought svn is the master, and not git. The git commit-id is
> eb7929b85ad87316a2437da03b4bb810cded7366 - it's between osg3.1.8 and 3.1.9

Thanks.  Git it now the master, we moved over not long ago.

> The problem we've is that mostly all of our models in the terrain are
> displayed transparent in the middle of the screen when using osgViewer
> class. Using the osgviewer executable all looks find so I assume osgviewer
> does not use osgViewer class.

I suspect this is an issue with your application not setting the
correct global state in the viewer's master Camera.  This issue was
discussed a great deal before and shortly after the 3.2 release, but
as you are just upgrading you have obviously missed this discussion.

There was a bug prior to OSG-3.2 where SceneView would discard global
StateSet values overwritting them with it's won global defaults.  The
bug fix addressed this problem so users could set the viewer's
Camera's StateSet and have this settings reflected in the scene.

While this change does fix a bug it inadvertently exposed a bug in
applications where they create their own osg::Camera without setting
any global default state then apply this directly to the viewer.  This
new osg::Camera then doesn't set any the defaults that are normally
assumed to be enabled such as depth test and alpha blending etc.  The
View(er) by default actually calls StateSet::setGlobalDefaults() but
this is done at intiialization of the View(er) so if you then replace
the View(er)'s Camera then you replace the one with the state set up
with some sensible global defaults with one with no StateSet set up.

The fix is to either just reuse the View(er)'s Camera rather than
replace it, or if do replace it call:

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

Robert.



More information about the osg-users mailing list