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

Sandro Mani manisandro at gmail.com
Mon Aug 21 04:42:14 PDT 2017


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.


at beginning of your program will ensure you'll get the context you 
actually asked for.

Any comments on this proposal?


[1] https://github.com/openscenegraph/OpenSceneGraph/pull/302






More information about the osg-users mailing list