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

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


Hi Robert


On 21.08.2017 17:43, Robert Osfield wrote:
> What GL version is osgEarth now depending upon?
A quick grep through the codebase shows shaders depending on GLSL up to 430.

> From an end users perspectives lack of compatibility profile is a 
> constraint, if it weren't you wouldn't have had any problems.  From 
> what you describe it may well be a temporary constraint.
I can't speak for the mesa developers, though search a bit one can read 
various statements here and there, including "A long time ago, a 
decision was made for Mesa not to increase the advertised compatibility 
profile version." 
(https://bugs.freedesktop.org/show_bug.cgi?id=96449#c5), so does not 
sound too temporary.

> 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>"

> 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.


If I use osgearth_qt_simple, the GL context created by Qt is used, which 
I can set up to use the desired version and profile mask, at which point 
things will also work with that viewer.

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


More information about the osg-users mailing list