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

55 views
Skip to first unread message

Andrew Cunningham

unread,
Dec 31, 2015, 1:35:24 PM12/31/15
to osg-...@lists.openscenegraph.org
Hi,
I am struggling mightily to get OSG 3.4.0 to work with QT 5.4.2 on Windows 7 (64).

- The sample application, OSGViewerQT works as expected with OSG_FILE_PATH set.

- However, when I ( as a quick test) embed the "ViewerWidget" from OSGViewerQT inside a QHBoxLayout inside a MainWindow, the ViewerWidget does not show any geometry ( e.g. the "cow.osgt" etc). Interestingly the "popupWidget" that displays the "truck" geometry works as expected - presumably as it is a separate Window. So there is some issue with embedding the OSG Widget(s) inside other QWidgets?

Any ideas???

Cheers,
Andrew

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65928#65928





_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Andrew Cunningham

unread,
Dec 31, 2015, 2:32:27 PM12/31/15
to osg-...@lists.openscenegraph.org

loopy wrote:
> Hi,
> I am struggling mightily to get OSG 3.4.0 to work with QT 5.4.2 on Windows 7 (64).
>
> - The sample application, OSGViewerQT works as expected with OSG_FILE_PATH set.
>
> - However, when I ( as a quick test) embed the "ViewerWidget" from OSGViewerQT inside a QHBoxLayout inside a MainWindow, the ViewerWidget does not show any geometry ( e.g. the "cow.osgt" etc). Interestingly the "popupWidget" that displays the "truck" geometry works as expected - presumably as it is a separate Window. So there is some issue with embedding the OSG Widget(s) inside other QWidgets?
>
>


OK, I sorted this one out. It was confusion over 'old ways' to use OSG/QT and the new, improved ways to do this.

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65929#65929

Eric Gregory

unread,
Dec 31, 2015, 2:46:36 PM12/31/15
to osg-...@lists.openscenegraph.org
What was the issue?

On December 31, 2015 11:36:23 AM PST, Andrew Cunningham <and...@mac.com> wrote:

loopy wrote:
Hi,
I am struggling mightily to get OSG 3.4.0 to work with QT 5.4.2 on Windows 7 (64).

- The sample application, OSGViewerQT works as expected with OSG_FILE_PATH set.

- However, when I ( as a quick test) embed the "ViewerWidget" from OSGViewerQT inside a QHBoxLayout inside a MainWindow, the ViewerWidget does not show any geometry ( e.g. the "cow.osgt" etc). Interestingly the "popupWidget" that displays the "truck" geometry works as expected - presumably as it is a separate Window. So there is some issue with embedding the OSG Widget(s) inside other QWidgets?




OK, I sorted this one out. It was confusion over 'old ways' to use OSG/QT and the new, improved ways to do this.

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65929#65929








--
Sent from my phone. Please excuse my brevity.

Andrew Cunningham

unread,
Jan 2, 2016, 11:34:07 AM1/2/16
to osg-...@lists.openscenegraph.org
I'm not 100% sure why the OSG example code stopped rendering correctly when embedded in my app as a test. I did get it working eventually.

Anyway, the underlying issue when trying to adapt the new OSG3.4/QT5 approach into my code code was that I completely missed ( too much holiday cheer?) that the 'actual' widget being rendered is found in graphicsWindow_->getGLWidget().

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65932#65932





_______________________________________________

Andrew Cunningham

unread,
Jan 4, 2016, 5:02:03 PM1/4/16
to osg-...@lists.openscenegraph.org
Hi,
Although I now have rendering of my objects happening in my Qt5/OSG 3.4.0 widget I am having a issue with simple polygonal objects rendering "on top of each other" as if there is no depth (Z) buffer in operation. I am using fairly vanilla OSG code to set up the model and camera that worked as expected in a MFC/OSG 3.0.1 world.

I am completely at a loss as to why a Z-buffer is not operating. GL_BLEND is definitively OFF.

Any ideas?
Thanks!

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65937#65937

Robert Osfield

unread,
Jan 4, 2016, 5:28:00 PM1/4/16
to OpenSceneGraph Users

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.

Andrew Cunningham

unread,
Jan 4, 2016, 5:42:07 PM1/4/16
to osg-...@lists.openscenegraph.org
Hmm,
I was able to fix it by adding the following to my root object state...

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

Not sure why this was needed in QT5/OSG as I thought it was the default...

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65939#65939

Andrew Cunningham

unread,
Jan 4, 2016, 5:53:33 PM1/4/16
to osg-...@lists.openscenegraph.org
[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

Robert Osfield

unread,
Jan 5, 2016, 5:03:09 AM1/5/16
to OpenSceneGraph Users
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.

Andrew Cunningham

unread,
Jan 11, 2016, 11:53:31 AM1/11/16
to osg-...@lists.openscenegraph.org
Ok, now I am having a new problem.
I am now transitioning to QT 5.5 and Visual Studio 2015 Update 1 from QT 5.4 and VS 2010 ( using OSG 3.4.0)

I rebuilt OSG for Visual Studio 2015 Update 1
I built QT5.5 for Visual Studio 2015 Update 1

The OSG examples all work fine, except OSGViewerQT

When osgViewerQT starts up

> osg130-osgd.dll!osg::State::initializeExtensionProcs() Line 959 C++
osg130-osgd.dll!osg::GraphicsContext::makeCurrent() Line 620 C++
osg130-osgQtd.dll!osgQt::GraphicsWindowQt::realizeImplementation() Line 777 C++
osg130-osgd.dll!osg::GraphicsContext::realize() Line 511 C++
osg130-osgViewerd.dll!osgViewer::CompositeViewer::realize() Line 612 C++
osg130-osgViewerd.dll!osgViewer::ViewerBase::frame(double simulationTime) Line 681 C++
osgviewerQtd.exe!ViewerWidget::paintEvent(QPaintEvent * event) Line 85 C++



const char* vendor = (const char*) glGetString( GL_VENDOR );

returns NULL, so of course nothing will work from now on.

Digging through the code, I found that in QGLContext::makeCurrent
> Qt5OpenGLd.dll!QGLContext::makeCurrent() Line 3578 C++
Qt5OpenGLd.dll!QGLWidget::makeCurrent() Line 4071 C++
osg130-osgQtd.dll!osgQt::GraphicsWindowQt::makeCurrentImplementation() Line 840 C++
osg130-osgd.dll!osg::GraphicsContext::makeCurrent() Line 611 C++
osg130-osgQtd.dll!osgQt::GraphicsWindowQt::realizeImplementation() Line 777 C++
osg130-osgd.dll!osg::GraphicsContext::realize() Line 511 C++


const char *renderer = reinterpret_cast<const char *>(d->guiGlContext->functions()->glGetString(GL_RENDERER));

returns a valid string...

Any ideas on this one? It looks like we do not have a valid GL context when OSG needs it.

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65981#65981

Andrew Cunningham

unread,
Jan 11, 2016, 1:48:21 PM1/11/16
to osg-...@lists.openscenegraph.org
I see my error, I built QT 5.5 with OpenGL ES 2 support, not desktop OpenGL support.

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65982#65982
Reply all
Reply to author
Forward
0 new messages