[osg-users] Updating app to latest OSG

OpenSceneGraph Users osg-users at lists.openscenegraph.org
Mon Sep 7 03:53:10 PDT 2020


Hi Robert,

Thanks for the comprehensive reply, I think I've done what you suggested but it doesn't appear to have changed anything.

This application uses osggtkdrawingarea which I've modified to work with GtkGLArea.

The viewer is added like so:

class OSGGTKDrawingArea : public osgViewer::Viewer {
osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> _gw;

...
}

_gw = setUpViewerAsEmbeddedInWindow(0, 0, width, height);

and in the realise callback I've added this:

getCamera()->setGraphicsContext(_gw);
    getCamera()->getOrCreateStateSet()->setGlobalDefaults();

I even tried explicitly setting depth test

getCamera()->getOrCreateStateSet()->setMode( GL_DEPTH_TEST, osg::StateAttribute::ON );

Still no joy.

I turned on GL_CULL_FACE just to check and it did what I expected so setting the camera attributes appears to be working.

Anything else you can think of tat I can try?

Cheers,


On Mon, 2020-09-07 at 09:12 +0100, OpenSceneGraph Users wrote:
Hi Franco,

Posting screenshots is fine, and exactly the thing to do with these types of problems.

It's not possible to diagnose the exact problem you are seeing with rendering under OSG-3.6.5.  Broadly it looks like a depth test issue.

I don't know if this is relevant, but will mention it as some others have been caught out by it. One of the bug fixes in the OSG-3.x series was to fix an override of the osg::Camera settings that was causing applications settings to be lost.  The fix had the side effect of revealing missing settings, in essence it was a bug A that hide a bug B that only occurred with certain usage models.

So bug A has been fixed and bug B usage case is an application creates a viewer osg::Camera, sets up a graphics context, then just directly assigns it to the viewer without setting any global state that is required for top level osg::Camera.  The state not set includes GL_DEPTH_TEST - which is where there "might" be an overlap with the problem you see with your application.

Normal OSG usage where you use the Viewer Camera's that are assigned by default also call StateSet::setGlobalDefaults() on this StateSet, so you never see a problem.  All the OSG examples provided in the OpenSceneGraph distribution do this.

However, the problem usage cause was something that was done in early osgQt based examples - they created a local osg::Camera assigned to the viewer and never called StateSet::setGlobalDefaults() on the osg::Camera's StateSet.   These examples used to work fine, even with this ill defined state because of Bug A.  If you copied one of these examples then you'll inherit this bug B usage case.

If this is the case then can either:

    1) Just use the viewer(views) Camera via Viewer/View::getCamera() to get the Camera to assign the GraphicsContext to, so utilize the default settings.
    2) Call:  camera->getOrCreateStateSet()->setGlobalDefaults() on the locally created Camera before it's assigned to the View(er).

There was a lot of discussion about this problem usage case and the solution when bug A was fixed and bug B revealed, but that's quite a few years ago now - had your software been updated more regularly it's likely you'll have seen discussions.

Cheers,
Robert.

_______________________________________________

osg-users mailing list

osg-users at lists.openscenegraph.org<mailto:osg-users at lists.openscenegraph.org>

http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20200907/8bb9eb5f/attachment.html>


More information about the osg-users mailing list