[osg-users] GL profiles issues on Windows

Robert Osfield robert.osfield at gmail.com
Wed Sep 5 08:23:33 PDT 2018


Hi Riccardo,

On Wed, 5 Sep 2018 at 15:56, Riccardo Corsi <riccardo.corsi at kairos3d.it> wrote:
> I've rebuilt osg as suggested by Robert and still getting no GL errors but nothing shows up.
> To sum it up, running a test app which only uses libA (which addresses only GL3 functions and shaders version 150)
> under windows:
> - if I link my code to OSG built with  GLCORE profile everything works
> - if I link the same code to OSG build with defaults, nothing shows up
>
> As further check, I tried the same with osgsimplegl3 example which works in both OSG builds.
> Any idea on what could be the culprit of my code not working in the same way?

My best guess is that the GLCORE build of the OSG is setting up the
osg::State vertex and uniform aliasing that you shaders are relying
upon, but in the default build of the OSG these are set by default so
you have to manually set them.

The osgsimplegl3 example illustrates and explains this:

    // for non GL3/GL4 and non GLES2 platforms we need enable the osg_
uniforms that the shaders will use,
    // you don't need thse two lines on GL3/GL4 and GLES2 specific
builds as these will be enable by default.
    gc->getState()->setUseModelViewAndProjectionUniforms(true);
    gc->getState()->setUseVertexAttributeAliasing(true);

These two settings are done by default for GLCORE build, but are off
by default so have to be set explicitly for non GLCORE builds.

The osgvertexattributes and osgtessellationshaders examples have a
more general purpose approach:

    osgViewer::Viewer::Windows windows;
    viewer.getWindows(windows);
    for(osgViewer::Viewer::Windows::iterator itr = windows.begin();
        itr != windows.end();
        ++itr)
    {
        osg::State *s=(*itr)->getState();
        s->setUseModelViewAndProjectionUniforms(true);
        s->setUseVertexAttributeAliasing(true);
    }

Probably the most general way to wrap this up would be to have a
custom RealizeOperation do this, the osgvolume example has an example
of this, although not for the State::setUse*Aliasing(true);

Hope this helps,
Robert.


More information about the osg-users mailing list