[osg-users] Specifying the GL context version to request

Sandro Mani manisandro at gmail.com
Mon Aug 21 09:41:07 PDT 2017



On 21.08.2017 18:34, Robert Osfield wrote:
> Hi Sandro,
>
> On 21 August 2017 at 17:21, Sandro Mani <manisandro at gmail.com 
> <mailto:manisandro at gmail.com>> wrote:
>
>     Are you building the OSG with defaults?  Or are you building the
>     OSG for just GL3?
>     %cmake -DBUILD_OSG_EXAMPLES=ON -DBUILD_DOCUMENTATION=ON
>     -DOSG_GL1_AVAILABLE=ON -DOSG_GL2_AVAILABLE=ON
>     -DOPENGL_PROFILE=GLCORE -DOPENGL_HEADER1="#include <GL/gl.h>"
>
>
> That's a bit of ugly mix.
Agreed, I didn't put much though into it, I just checked that I hit the 
OSG_GL3_FEATURES when doing the work on the context.
> Things should work with just:
>
> cmake .
> make -j 4   # 4 is number of cores available
>
> When you using the OPENGL_PROFILE it'll set the OSG_*_AVAILABLE 
> options for you, but in general build with defaults unless you 
> specifically need a particular feature set.
Well, in this case I needed it though, right? I mean, OPENGL_PROFILE 
defaults to "GL2".
>
>
>>     What viewer are using with osgEarth? osgEarth itself is typically
>>     used as NodeKit with end user application creating their own
>>     viewer and with it graphics contexts.  This means even if
>>     osgEarth's own example programs changed the way they create
>>     graphics context you'd end up with issues.
>     Running with osgearth_viewer, I get two calls to
>     osgViewer::GraphicsWindowX11::init. The first one where, I assume,
>     it tries to determine the capabilities of hardware/driver in use,
>     and this calls Traits without a DisplaySettings instance:
>
>     #0  osgViewer::GraphicsWindowX11::init (this=this at entry=0x1004ad330)
>         at
>     /usr/src/debug/OpenSceneGraph-3.5.7-0.2.gitbfbaeca.fc27.x86_64/src/osgViewer/GraphicsWindowX11.cpp:915
>     #1  0x00007f3e23ae4b50 in
>     osgViewer::GraphicsWindowX11::GraphicsWindowX11
>     (traits=0x1003760d0, this=<optimized out>)
>         at
>     /usr/src/debug/OpenSceneGraph-3.5.7-0.2.gitbfbaeca.fc27.x86_64/include/osgViewer/api/X11/GraphicsWindowX11:56
>     #2  X11WindowingSystemInterface::createGraphicsContext
>     (this=<optimized out>, traits=0x1003760d0)
>         at
>     /usr/src/debug/OpenSceneGraph-3.5.7-0.2.gitbfbaeca.fc27.x86_64/src/osgViewer/GraphicsWindowX11.cpp:2269
>     #3  0x00007f3e241e81b7 in
>     osg::GraphicsContext::createGraphicsContext
>     (traits=traits at entry=0x1003760d0)
>         at
>     /usr/src/debug/OpenSceneGraph-3.5.7-0.2.gitbfbaeca.fc27.x86_64/src/osg/GraphicsContext.cpp:128
>     #4  0x00007f3e2350c256 in MyGraphicsContext::MyGraphicsContext
>     (this=<synthetic pointer>)
>         at
>     /usr/src/debug/osgearth-2.9-0.2.git43d4ba5.fc27.x86_64/src/osgEarth/Capabilities.cpp:76
>     #5  osgEarth::Capabilities::Capabilities (this=0x100390f30)
>         at
>     /usr/src/debug/osgearth-2.9-0.2.git43d4ba5.fc27.x86_64/src/osgEarth/Capabilities.cpp:162
>     #6  0x00007f3e236897a5 in osgEarth::Registry::initCapabilities
>     (this=0x1002a7af0)
>         at
>     /usr/src/debug/osgearth-2.9-0.2.git43d4ba5.fc27.x86_64/src/osgEarth/Registry.cpp:484
>     #7  0x00007f3e23689829 in osgEarth::Registry::getCapabilities
>     (this=0x1002a7af0)
>         at
>     /usr/src/debug/osgearth-2.9-0.2.git43d4ba5.fc27.x86_64/src/osgEarth/Registry.cpp:468
>     #8  0x00007f3dfa209486 in osgEarth::Registry::capabilities ()
>         at
>     /usr/src/debug/osgearth-2.9-0.2.git43d4ba5.fc27.x86_64/src/osgEarth/Registry:149
>     #9
>     osgEarth::Drivers::MPTerrainEngine::MPTerrainEngineNode::MPTerrainEngineNode
>     (this=0x100a1ac60)
>         at
>     /usr/src/debug/osgearth-2.9-0.2.git43d4ba5.fc27.x86_64/src/osgEarthDrivers/engine_mp/MPTerrainEngineNode.cpp:202
>     [...]
>
>     Then, a second time here:
>
>     #0  osgViewer::GraphicsWindowX11::init (this=this at entry=0x100676840)
>         at
>     /usr/src/debug/OpenSceneGraph-3.5.7-0.2.gitbfbaeca.fc27.x86_64/src/osgViewer/GraphicsWindowX11.cpp:915
>     #1  0x00007f3e23ae4b50 in
>     osgViewer::GraphicsWindowX11::GraphicsWindowX11
>     (traits=0x10052c100, this=<optimized out>)
>         at
>     /usr/src/debug/OpenSceneGraph-3.5.7-0.2.gitbfbaeca.fc27.x86_64/include/osgViewer/api/X11/GraphicsWindowX11:56
>     #2  X11WindowingSystemInterface::createGraphicsContext
>     (this=<optimized out>, traits=0x10052c100)
>         at
>     /usr/src/debug/OpenSceneGraph-3.5.7-0.2.gitbfbaeca.fc27.x86_64/src/osgViewer/GraphicsWindowX11.cpp:2269
>     #3  0x00007f3e241e81b7 in
>     osg::GraphicsContext::createGraphicsContext
>     (traits=traits at entry=0x10052c100)
>         at
>     /usr/src/debug/OpenSceneGraph-3.5.7-0.2.gitbfbaeca.fc27.x86_64/src/osg/GraphicsContext.cpp:128
>     #4  0x00007f3e23a7ab62 in osgViewer::SingleWindow::configure
>     (this=0x100a2a370, view=...)
>         at
>     /usr/src/debug/OpenSceneGraph-3.5.7-0.2.gitbfbaeca.fc27.x86_64/src/osgViewer/config/SingleWindow.cpp:72
>     #5  0x00007f3e23a7a80a in osgViewer::SingleScreen::configure
>     (this=<optimized out>, view=...)
>         at
>     /usr/src/debug/OpenSceneGraph-3.5.7-0.2.gitbfbaeca.fc27.x86_64/src/osgViewer/config/SingleScreen.cpp:29
>     #6  0x00007f3e23a75207 in osgViewer::AcrossAllScreens::configure
>     (this=<optimized out>, view=...)
>         at
>     /usr/src/debug/OpenSceneGraph-3.5.7-0.2.gitbfbaeca.fc27.x86_64/src/osgViewer/config/AcrossAllScreens.cpp:48
>     #7  0x00007f3e23ab79c2 in osgViewer::View::apply
>     (this=0x7fffffffdb00, config=0x1002a3770)
>         at
>     /usr/src/debug/OpenSceneGraph-3.5.7-0.2.gitbfbaeca.fc27.x86_64/src/osgViewer/View.cpp:456
>     #8  0x00007f3e23ab7b00 in
>     osgViewer::View::setUpViewAcrossAllScreens (this=<optimized out>)
>         at
>     /usr/src/debug/OpenSceneGraph-3.5.7-0.2.gitbfbaeca.fc27.x86_64/src/osgViewer/View.cpp:463
>     [...]
>
>     using ViewAcrossAllScreens as you anticipated and hence the
>     default DisplaySettings. Since by default a "1.0" context is
>     created, the result is:
>
>     FRAGMENT glCompileShader "main(fragment)" FAILED
>     FRAGMENT Shader "main(fragment)" infolog:
>     0:1(10): error: GLSL 3.30 is not supported. Supported versions
>     are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES
>
>     etc.
>
>     If I add
>
>     osg::DisplaySettings::instance()->setGLContextVersion( "4.0" );
>     osg::DisplaySettings::instance()->setGLContextProfileMask( 0x1 );
>
>     at the beginning of a tweaked osgearth_viewer.cpp at main, things
>     work (though possibly osgEarth::Capabilities::Capabilities will
>     have incorrectly determined some things since a "1.0" context was
>     created there). The same effect can indeed be achieved by using
>     the environment variables you mention.
>
>
> Try using the OSG_GL_CONTEXT_VERSION and OSG_GL_CONTEXT_PROFILE_MASK 
> env vars instead of the above DisplaySettings::instance() code i,e,
>
> export OSG_GL_CONTEXT_VERSION=4.0
> export OSG_GL_CONTEXT_PROFILE_MASK=1
Yes as mentioned this also works. But the open issue for me still 
remains the first context created by osgEarth::Capabilities::
Capabilities (see first of the stack traces I posted above). In my view 
either this is a bug in osgEarth that it creates the traits without 
honouring the desired GL version, or OSG should otherwise ensure the 
traits contain the overridden GL version.

Sandro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20170821/4dd1e2ac/attachment.htm>


More information about the osg-users mailing list