[osg-users] Specifying the GL context version to request
Sandro Mani
manisandro at gmail.com
Mon Aug 21 04:42:14 PDT 2017
Hi
To get OpenSceneGraph with GL3.2+ working on GLX, in pull request 302
[1] I've proposed adding support for specifying the GL version, profile
and context flags on GLX via the traits fields
std::string glContextVersion;
unsigned int glContextFlags;
unsigned int glContextProfileMask;
So far these were only honored by GraphicsWindowWin32.
This work has now been merged [2].
There is however still one open issue, namely how to properly and
reliably get the context you ask for. There are the methods
setGLContext{Version,Flags,ProfileMask} in DisplaySettings [3] which
seems the appropriate way to do so, but the display settings (and hence
these settings) are only honored by the Traits constructor if a
DisplaySettings instance is explicitly specified [4]. However, as far as
I can see, this seldom is done (just grep for "new
osg::GraphicsContext::Traits" throughout the codebase and you can see
that often the traits are constructed without a DisplaySettings instance).
My suggestion would be to always fall back to the global DisplaySettings
singleton [5] if none is passed to the Traits constructor, as proposed
here [6].
This way, writing once i.e.
osg::DisplaySettings::instance()->setGLContextVersion("4.0");
osg::DisplaySettings::instance()->setGLContextProfileMask(0x1);
at beginning of your program will ensure you'll get the context you
actually asked for.
Any comments on this proposal?
Thanks
Sandro
[1] https://github.com/openscenegraph/OpenSceneGraph/pull/302
[2]
https://github.com/openscenegraph/OpenSceneGraph/commit/8926f0e9c253a1781e6cdbde96ec467324bb105c
[3]
https://github.com/openscenegraph/OpenSceneGraph/blob/master/include/osg/DisplaySettings#L279
[4]
https://github.com/openscenegraph/OpenSceneGraph/blob/master/src/osg/GraphicsContext.cpp#L249
[5]
https://github.com/openscenegraph/OpenSceneGraph/blob/master/include/osg/DisplaySettings#L38
[6]
https://github.com/openscenegraph/OpenSceneGraph/pull/302#issuecomment-323189245
More information about the osg-users
mailing list