[osg-users] getWindowingSystemInterface() fails on Ubuntu 18.04

Omar Álvarez omar.alvarez at cinfo.es
Wed Sep 5 09:06:27 PDT 2018


Hi Robert,

Your answer almost fixed my issue. There is just one
problem  wsi->getScreenSettings(), still queries the wrong session:

1 screen(s) detected
Invalid MIT-MAGIC-COOKIE-1 keyUnable to open display ":0.1".
  Screen #0 : 0x0 0Hz 0 bit

The problem is screen_id(screen), since it is not 0. The proper call would
be:

osg::GraphicsContext::ScreenIdentifier screen_id(main_screen_id.hostName,
main_screen_id.displayNum, screen);

I will update the test repo with the proper code.

Thank you very much for your time. If nobody else feels like doing it, I
can help with updating osg::GraphicsContext::WindowingSystemInterface.

Cheers,

Omar.

2018-09-05 16:50 GMT+02:00 Robert Osfield <robert.osfield at gmail.com>:

> On Wed, 5 Sep 2018 at 15:22, Julien Valentin <julienvalentin51 at gmail.com>
> wrote:
> > for your code you should replace
> > wsi->getNumScreens()
> > with
> > wsi->getNumScreens(osg::GraphicsContext::ScreenIdentifier(1))
> > to work on DISPLAY=:1.0
>
> Sounds like we are getting to the bottom of things now :-)
>
> FYI, WindowingSystemInterface::getNumScreens() is implemented in
> include/osg/GraphicsContext as:
>
>             virtual unsigned int getNumScreens(const ScreenIdentifier&
> screenIdentifier = ScreenIdentifier()) = 0;
>
> The default constructed ScreenIdentifier is:
>
> GraphicsContext::ScreenIdentifier::ScreenIdentifier():
>     displayNum(0),
>     screenNum(0) {}
>
> Which is fine if the system doesn't change the default DISPLAY from 0.0.
>
> Support for DISPLAY is actually built into ScreenIdentifier via the
> readDISPLAY() method:
>
>             /** Read the DISPLAY environmental variable, and set the
> ScreenIdentifier accordingly.
>               * Note, if either of displayNum or screenNum are not
> defined then -1 is set respectively to
>               * signify that this parameter has not been set. When
> parameters are undefined one can call
>               * call setUndefinedScreenDetailsToDefaultScreen() after
> readDISPLAY() to ensure valid values. */
>             void readDISPLAY();
>
> To is not called by the constructor though, so you need to call it
> explicitly.  The various Viewer config implementations do actually
> call readDISPLAY:
>
> ~/OpenSceneGraph/src/osgViewer$ grep readDISPLAY */*.cpp
> config/AcrossAllScreens.cpp:    si.readDISPLAY();
> config/PanoramicSphericalDisplay.cpp:    si.readDISPLAY();
> config/SingleWindow.cpp:    traits->readDISPLAY();
> config/SingleWindow.cpp:        si.readDISPLAY();
> config/SphericalDisplay.cpp:    si.readDISPLAY();
> config/WoWVxDisplay.cpp:    si.readDISPLAY();
>
> So I'd suggest using this, such as (modified main.cpp for osgtest:
>
>     std::cout << wsi->getNumScreens() << " screen(s) detected" <<
> std::endl;
>     for ( unsigned int screen=0 ; screen <
> wsi->getNumScreens(main_screen_id); screen++ )
>     {
>         osg::GraphicsContext::ScreenIdentifier screen_id(screen);
>         osg::GraphicsContext::ScreenSettings screen_settings;
>         wsi->getScreenSettings( screen_id, screen_settings );
>         std::cout << "  Screen #" << screen << " : "
>                   << screen_settings.width << "x" <<
> screen_settings.height << " "
>                   << screen_settings.refreshRate << "Hz "
>                   << screen_settings.colorDepth << " bit" << std::endl;
>     }
>
> I have also attached the full modified file.
>
> Robert.
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20180905/7759b09a/attachment.html>


More information about the osg-users mailing list